jquery之多重判断
var appPath = getAppPath();
$(function(){
$('#addTeskDlg').window('close');
teskGrid();
});
function teskGrid(){
$('#teskGrid').datagrid({
url:appPath+'/page/orderManualTesk/list',
method:'post',
// queryParams:getQueryParam(),
height:'full',
width:'full',
singleSelect:true,
striped: true,
remoteSort:false,
checkbox:false,
idField:'omId',
frozenColumns:[[
{field:'id',title:'操作',width:'80',align:'left',
formatter:function(value,rowData,rowIndex){
var dataStr = JSON.stringify(rowData);
return "<a href='javascript:void(0)'><img width='12px' height='12px' style='border:0px;' src='"+appPath+"/js/lib/jquery-easyui/themes/icons/pencil.png' title='编辑' onClick='showEdit("+dataStr+")'/></a> " +
"<a href='javascript:void(0)'><img width='12px' height='12px' style='border:0px;' src='"+appPath+"/js/lib/jquery-easyui/themes/icons/cancel.png' title='删除' onClick='del("+dataStr+")'/></a>";
}
}
]],
columns:[[
{field:'goodsNo',title:'商品编码',width:80,align:'center',sortable:true},
{field:'goodsName',title:'商品名称',width:120,align:'center',sortable:true},
{field:'isCycle',title:'是否循环',width:80,align:'center',sortable:true,
formatter:function(value,rowData,rowIndex){
if(rowData.isCycle=='Y'){
return '是';
}else{
return '否';
}
}},
{field:'moCount',title:'周一的数量',width:80,align:'center',sortable:true},
{field:'tuCount',title:'周二的数量',width:80,align:'center',sortable:true},
{field:'weCount',title:'周三的数量',width:80,align:'center',sortable:true},
{field:'thCount',title:'周四的数量',width:80,align:'center',sortable:true},
{field:'frCount',title:'周五的数量',width:80,align:'center',sortable:true},
{field:'saCount',title:'周六的数量',width:80,align:'center',sortable:true},
{field:'suCount',title:'周日的数量',width:80,align:'center',sortable:true},
{field:'state',title:'状态',width:60,align:'center',sortable:true,
formatter:function(value,rowData,rowIndex){
if(rowData.state=='0'){
return '待处理';
}else if(rowData.state=='1'){
return '已结束';
}else{
return rowData.state;
}
}}
]],
pagination:true,
rownumbers:true,
toolbar:[{
id:'btnadd',
text:'新增',
iconCls:'icon-add',
handler:function(){
showEdit(null);
}
}
]
});
}
function doQuery(){
var param = new Object;
param.goodsNo = $.trim($('#goodsNo').val());
param.state = $("#state").combobox("getValue");
$("#teskGrid").datagrid('unselectAll');
$("#teskGrid").datagrid('load',param);
}
function closeAddTeskDlg(){
$('#addTeskDlg').window('close');
}
function saveTesk(){
//商品编码
var goodsNo = $.trim($('#goodsNoText').val());
//是否循环
var isCycle = 'N';
if( $('input:checkbox[id="isCycleText"]:checked').val()){
isCycle = 'Y';
}
var moCount = $.trim($('#moCountText').val());
var tuCount = $.trim($('#tuCountText').val());
var weCount = $.trim($('#weCountText').val());
var thCount = $.trim($('#thCountText').val());
var frCount = $.trim($('#frCountText').val());
var saCount = $.trim($('#saCountText').val());
var suCount = $.trim($('#suCountText').val());
if(goodsNo==''){
$('#goodsNoTextNot').css('display','');
return;
}else{
$('#goodsNoTextNot').css('display','none');
}
if(moCount!=null&&moCount!=''&&isNaN(moCount)){
$('#moCountTextNot').css('display','');
return;
}else{
$('#moCountTextNot').css('display','none');
}
if(tuCount!=null&&tuCount!=''&&isNaN(tuCount)){
$('#tuCountTextNot').css('display','');
return;
}else{
$('#tuCountTextNot').css('display','none');
}
if(weCount!=null&&weCount!=''&&isNaN(weCount)){
$('#weCountTextNot').css('display','');
return;
}else{
$('#weCountTextNot').css('display','none');
}
if(thCount!=null&&thCount!=''&&isNaN(thCount)){
$('#thCountTextNot').css('display','');
return;
}else{
$('#thCountTextNot').css('display','none');
}
if(frCount!=null&&frCount!=''&&isNaN(frCount)){
$('#frCountTextNot').css('display','');
return;
}else{
$('#frCountTextNot').css('display','none');
}
if(saCount!=null&&saCount!=''&&isNaN(saCount)){
$('#saCountTextNot').css('display','');
return;
}else{
$('#saCountTextNot').css('display','none');
}
if(suCount!=null&&suCount!=''&&isNaN(suCount)){
$('#suCountTextNot').css('display','');
return;
}else{
$('#suCountTextNot').css('display','none');
}
var mod = $("<div class='panel window' style='position: absolute;text-align:center;top:50%;left:50%;z-index:9100'>" +
"<img src='"+appPath+"/images/common/loading.gif'><br/>正在保存</div>" +
"<div class='window-mask' style='z-index:9100'></div>");
mod.appendTo('body');
var param = new Object;
param.omId = $('#omId').val();
param.isCycle = isCycle;
param.goodsNo = goodsNo;
param.moCount = moCount;
param.tuCount = tuCount;
param.weCount = weCount;
param.thCount = thCount;
param.frCount = frCount;
param.saCount = saCount;
param.suCount = suCount;
doAjax({
url:appPath+'/page/orderManualTesk/getGoodsByNo',
type:'post',
data:{goodsNo:goodsNo},
success:function(data){
if(data.goodsId!=null&&data.goodsId!=''){
doAjax({
url:appPath+'/page/orderManualTesk/addOrUpdateTask',
type:'post',
data:param,
success:function(data){
mod.remove();
if(data=='ok'){
$.messager.alert('提示信息','保存成功','info');
}
doTeskReload();
$('#addTeskDlg').window('close');
},
error:function(XMLHttpRequest, textStatus, errorThrown){
mod.remove();
$.messager.alert('提示信息','抱歉,保存失败,'+textStatus,'error');
doTeskReload();
}
});
}else{
mod.remove();
$.messager.alert('提示信息','请填写正确的商品编号','info');
}
},
error:function(XMLHttpRequest, textStatus, errorThrown){
mod.remove();
$.messager.alert('提示信息','查询商品信息失败,'+textStatus,'error');
doTeskReload();
}
});
}
function doTeskReload(){
$('#teskGrid').datagrid('unselectAll');
$('#teskGrid').datagrid('reload');
$('#addTeskDlg').window('close');
}
//删除数据
function del(rowData){
$.messager.confirm('提示信息','您确定要删除这条记录?',function(r){
if(r){
doAjax({
url:appPath+'/page/orderManualTesk/del',
type:'post',
data:{omId:rowData.omId},
success:function(data){
if(data='ok'){
$.messager.alert('提示信息','删除成功!','info');
}
doTeskReload();
},
error:function(XMLHttpRequest, textStatus, errorThrown){
$.messager.alert('提示信息','删除失败!','info');
doTeskReload();
}
});
}
});
}
//显示编辑页面
function showEdit(rowData){
if(rowData!=null){
$('#addTaskForm').form('clear');
$('#addTaskForm').form('load',rowData);
$('#omId').val(rowData.omId);
$('#goodsNoText').val(rowData.goodsNo);
$('#moCountText').val(rowData.moCount);
$('#tuCountText').val(rowData.tuCount);
$('#weCountText').val(rowData.weCount);
$('#thCountText').val(rowData.thCount);
$('#frCountText').val(rowData.frCount);
$('#saCountText').val(rowData.saCount);
$('#suCountText').val(rowData.suCount);
if(rowData.isCycle == 'Y'){
document.getElementById("isCycleText").checked = true;
}else{
document.getElementById("isCycleText").checked = false;
}
}else{
$('#omId').val('');
$('#goodsNoText').val('');
$('#moCountText').val('');
$('#tuCountText').val('');
$('#weCountText').val('');
$('#thCountText').val('');
$('#frCountText').val('');
$('#saCountText').val('');
$('#suCountText').val('');
document.getElementById("isCycleText").checked = false;
}
$('#addTeskDlg').window({
title:'编辑',
iconCls:'icon-add',
width:500,
height:300,
left:100,
modal: true,
shadow: true,
collapsible:false,
minimizable:false,
maximizable:false
});
$('#addTeskDlg').window('move',{top:100});
$('#addTeskDlg').window('open');
}
===================================================================
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script src="${ctx }/js/orderManual/orderManualTesk.js"></script>
<body>
<table class="queryTable" width="100%" >
<tr>
<td class="queryTitle" width="100">商品编码</td>
<td class="queryContent" width="100">
<input class="inputText" type="text" id="goodsNo" />
</td>
<td class="queryTitle" width="100">状态</td>
<td class="queryContent" width="100">
<select id="state" class="easyui-combobox" style="width: 100px" panelHeight="auto">
<option value="">请选择</option>
<option value="0">待处理</option>
<option value="1">已结束</option>
</select>
</td>
<td>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="doQuery()" iconCls="icon-search" >查询</a>
</td>
</tr>
</table>
<table id="teskGrid" ></table>
<input type="hidden" id="omId" name="omId" />
<!-- 优惠券黑名单--编辑 -->
<div id="addTeskDlg" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:200px;text-align:center; background: #fafafa;">
<div class="easyui-layout" fit="true">
<div region="center" border="false" style="background:#fff;border:1px solid #ccc;">
<form id="addTaskForm" method="POST">
<table class="queryTable" width="100%" >
<tr>
<td class="queryTitle" width="100">商品编码</td>
<td class="queryContent" width="100" colspan="3">
<input class="inputText" type="text" id="goodsNoText" />
<label id="goodsNoTextNot" style="color: red;display: none;">* 商品编码不能为空</label>
<input type="checkbox" id="isCycleText" />是否循环
</td>
</tr>
<tr>
<td class="queryTitle" width="100">周一的数量</td>
<td class="queryContent" width="100">
<input class="inputText" type="text" id="moCountText" />
<label id="moCountTextNot" style="color: red;display: none;">* 周一的数量应为数字</label>
</td>
<td class="queryTitle" width="100">周二的数量</td>
<td class="queryContent" width="100">
<input class="inputText" type="text" id="tuCountText" />
<label id="tuCountTextNot" style="color: red;display: none;">* 周二的数量应为数字</label>
</td>
</tr>
<tr>
<td class="queryTitle" width="100">周三的数量</td>
<td class="queryContent" width="100">
<input class="inputText" type="text" id="weCountText" />
<label id="weCountTextNot" style="color: red;display: none;">* 周三的数量应为数字</label>
</td>
<td class="queryTitle" width="100">周四的数量</td>
<td class="queryContent" width="100">
<input class="inputText" type="text" id="thCountText" />
<label id="thCountTextNot" style="color: red;display: none;">* 周四的数量应为数字</label>
</td>
</tr>
<tr>
<td class="queryTitle" width="100">周五的数量</td>
<td class="queryContent" width="100">
<input class="inputText" type="text" id="frCountText" />
<label id="frCountTextNot" style="color: red;display: none;">* 周五的数量应为数字</label>
</td>
<td class="queryTitle" width="100">周六的数量</td>
<td class="queryContent" width="100">
<input class="inputText" type="text" id="saCountText" />
<label id="saCountTextNot" style="color: red;display: none;">* 周六的数量应为数字</label>
</td>
</tr>
<tr>
<td class="queryTitle" width="100">周日的数量</td>
<td class="queryContent" width="100" colspan="3">
<input class="inputText" type="text" id="suCountText" />
<label id="suCountTextNot" style="color: red;display: none;">* 周日的数量应为数字</label>
</td>
</tr>
</table>
</form>
</div>
<div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">
<a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="saveTesk()">保存</a>
<a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0)" onclick="closeAddTeskDlg()">取消</a>
</div>
</div>
</div>
</body>
jquery之多重判断的更多相关文章
- PHP多重判断删除文件函数
<?function delete_file($file) { if (file_exists($file)) { $delete = chmod ($file, ...
- jQuery如何去判断页面是否有父页面?
jQuery如何去判断页面是否有父页面? 是要判断当前页面是否被嵌入在frame里吗? 1 2 3 if (top != self) { alert('我在框架里'); }
- case....when ...多重判断
CASE...WHEN 进行多重判断 CASE WHEN A IS NOT NULL THEN B WHEN C IS NULL THEN CASE WHEN D IS NOT NULL THEN ...
- JS流程控制语句 多重判断满足你各种需求 要在多组语句中选择一组来执行,使用if..else嵌套语句。
多重判断(if..else嵌套语句) 要在多组语句中选择一组来执行,使用if..else嵌套语句. 语法: if(条件1) { 条件1成立时执行的代码} else if(条件2) { 条件2成立时执行 ...
- JavaScript和jQuery的类型判断
此博文为原创,转载请注明出处! 对于类型的判断,JavaScript用typeof来进行. 栗子: console.log(typeof null); //object console.log(typ ...
- jquery获取多重input的方式
获取input的checked值是否为true: 第一种: if($("input[name=item][value='val']").attr('checked')==true) ...
- jQuery基础 -- 如何判断页面元素存在与否
在传统的Javascript里,当我们对某个页面元素进行某种操作前,最好先判断这个元素是否存在.原因是对一个不存在的元素进行操作是不允许的.例如: document.getElementById(&q ...
- jquery checkbox的判断和设置方法
jquery的操作复选框偶尔能用到,每次都是百度去查,不得不说现在百度的搜索真的很垃圾,好多特别老的文章都排在前面,想要甄别出有用的东西挺费劲.脑子又记不住这么多东西,好记性不如烂笔头,还是记下来吧 ...
- jquery and js 判断一个元素是否存在
一.javascript中判断一个元素是否存在 if(document.getElementById('example')){ // do sth } 二.jquery中判断一个元素是否存在 < ...
随机推荐
- 软件测试 homework2
1. 程序1: for循环的i>0改为i>=0: 程序2: for循环for (int i = 0; i < x.length; i++)改为for (int i = x.l ...
- C#中英文混合字符串过长截断
/// <summary> /// 截断字符串 /// </summary> /// <param name="maxLength">最大长度& ...
- 在MyEclipse中设置Source folders和output folder
在一个项目中可能会有多个资源文件,它们共同编译输出到输出文件.那么除了默认的src以外,如何把其他文件设置成资源文件(Source folders)呢?
- [转]《深度探索C++对象模型》读书笔记[二]
3.3 Data Member的存取1. 不管什么情况,每一个static data member只有一个实体,放在程序的data segment之中,每次程序取用static member,不管 ...
- hdu 1241
1.题目大意:给定一个图,上边有*和@两种标记,其中@表示石油,好多@连在一起可以看成一个大的石油区,问在这个区域中有多少个石油区 #include<iostream> using nam ...
- 1.一个.java源文件中是否可以包括多个类?2...
1.一个“.java”源文件中是否可以包括多个类(不是内部类)?有什么限制? 答:可以有多个类,但只能有一个public类,并且public的类名必须与文件名相一致. 2.java有没有goto? 答 ...
- php explode 用法详解
定义和用法explode() 函数把字符串分割为数组. 语法explode(separator,string,limit)参数 描述 separator 必需.规定在哪里分割字符串.string 必需 ...
- 怎么把QQ我的收藏表情图片转移到另一台电脑上
把收藏的QQ表情从一台电脑转移到另一台电脑的操作步骤如下: 1.在有表情的电脑登陆QQ,随便打开一个聊天窗口,点击[表情],选择[表情设置],点击[导入导出表情包],选择[导出全部表情包]: ...
- iOS UITableView的使用大全-备用
首先.对UITableView进行讲解,下面有对它进行实际的应用 UITableView 显示大型内容的列表 单行,多列 垂直滚动,没有水平滚动 大量的数据集 性能强大,而且普遍存在于iPhone的应 ...
- AndroidStudio1.1.0配置使用androidannotations
1:从GitHub上下载最新版androidannotations-api-3.3.1.jar 2:新建Module:my-aa-test 3:将androidannotations-api-3.3. ...