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> &nbsp;" +
                              "<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>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>
                        &nbsp;&nbsp;&nbsp;<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>&nbsp;&nbsp;
            <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0)" onclick="closeAddTeskDlg()">取消</a>
        </div>
    </div>
</div>

</body>

jquery之多重判断的更多相关文章

  1. PHP多重判断删除文件函数

    <?function delete_file($file) {     if (file_exists($file))     {         $delete = chmod ($file, ...

  2. jQuery如何去判断页面是否有父页面?

    jQuery如何去判断页面是否有父页面?     是要判断当前页面是否被嵌入在frame里吗? 1 2 3 if (top != self) {     alert('我在框架里'); }

  3. case....when ...多重判断

    CASE...WHEN 进行多重判断 CASE WHEN A  IS NOT NULL THEN B WHEN C IS NULL THEN CASE WHEN D IS NOT NULL THEN ...

  4. JS流程控制语句 多重判断满足你各种需求 要在多组语句中选择一组来执行,使用if..else嵌套语句。

    多重判断(if..else嵌套语句) 要在多组语句中选择一组来执行,使用if..else嵌套语句. 语法: if(条件1) { 条件1成立时执行的代码} else if(条件2) { 条件2成立时执行 ...

  5. JavaScript和jQuery的类型判断

    此博文为原创,转载请注明出处! 对于类型的判断,JavaScript用typeof来进行. 栗子: console.log(typeof null); //object console.log(typ ...

  6. jquery获取多重input的方式

    获取input的checked值是否为true: 第一种: if($("input[name=item][value='val']").attr('checked')==true) ...

  7. jQuery基础 -- 如何判断页面元素存在与否

    在传统的Javascript里,当我们对某个页面元素进行某种操作前,最好先判断这个元素是否存在.原因是对一个不存在的元素进行操作是不允许的.例如: document.getElementById(&q ...

  8. jquery checkbox的判断和设置方法

    jquery的操作复选框偶尔能用到,每次都是百度去查,不得不说现在百度的搜索真的很垃圾,好多特别老的文章都排在前面,想要甄别出有用的东西挺费劲.脑子又记不住这么多东西,好记性不如烂笔头,还是记下来吧 ...

  9. jquery and js 判断一个元素是否存在

    一.javascript中判断一个元素是否存在 if(document.getElementById('example')){ // do sth } 二.jquery中判断一个元素是否存在 < ...

随机推荐

  1. SQL用row_number进行高速循环

    SQL用row_number进行循环查询 declare @count int=0,@R int=0select row_number()over(order by RoomID) as R,* in ...

  2. 如何修改TextField的Label和EmptyText

    在需求中常常有修改form表单的标签和空文本提示,在渲染后组件有些字符固定下来 除非使用document进行原始修改,通过查询stackflow,我介绍更方便方法 模拟场景:点击ChangeLabel ...

  3. JS数组常用方法

      // 来自 http://www.runoob.com/jsref/jsref-obj-array.html   var arr01 = [ "fuc" , "shi ...

  4. explicit 关键字

    C++ explicit关键字用来修饰类的构造函数,表明该构造函数是显式的,既然有"显式"那么必然就有"隐式",那么什么是显示而什么又是隐式的呢? 如果c++类 ...

  5. C++ Const成员函数

    一些成员函数改变对象,一些成员函数不改变对象. 例如:  int Point::GetY() { return yVal; }  这个函数被调用时,不改变Point对象,而下面的函数改变Point对象 ...

  6. 新安装ubuntu后几项配置

    新安的ubuntu13.04 为了编程方便 进行如下设置 安装右键terminal    sudo apt-get install nautilus-open-terminal 安装远程连接ssh   ...

  7. swift和 oc 混编2-备

    在Swift语言出现之前,开发iOS或OS X应用主要使用Objective-C语言,此外还可以使用C和C++语言,但是UI部分只能使用Objective-C语言. 选择语言 Swift语言出现后,苹 ...

  8. Swift— Swift编码规范之命名规范-备

    程序代码中到处都是自己定义的名字,取一个有样并且符合规范的名字非常重要. 命名方法很多,但是比较有名的,广泛接受命名法有: 匈牙利命名,一般只是命名变量,原则是:变量名=类型前缀+描述,如bFoo表示 ...

  9. android 设置背景为空(透明)

    在给控件设置背景时像ps那样的背景透明 在3.0以下可以使用 imageView.setBackgroundResource(android.R.id.empty); 但是这个方法在3.0以上会出现 ...

  10. android:onclick属性

    android:onclick属性设置点击时从上下文中调用指定的方法,此时给指定一个方法名.例如: xml中: <Button android:layout_width="wrap_c ...