Ext页面 用到了Ext.ux.SliderTip

controlOrder = function() {
    var grid, ds;
    var pageSize = 20;
    var upTbar;
    var searchBtn, addBtn, deleteBtn, updateBtn;
    var cm;
    var gridDSURL = 'wagerControl__queryAll.action';
    /* ----------------------- private方法 ----------------------- */

    /*
     * 创建表格
     */
    function createGrid() {
        // 定义每一行显示的字段,其中mapping为json传入时的名称
        var recordDef = Ext.data.Record.create([ {
            name : 'merchantname',
            mapping : 'merchantname'
        }, {
            name : 'gamename',
            mapping : 'gamename'
        }, {
            name : 'merchantid',
            mapping : 'merchantid'
        }, {
            name : 'ltype',
            mapping : 'ltype'
        }, {
            name : 'proportion',
            mapping : 'proportion'
        }, {
            name : 'dayamount',
            mapping : 'dayamount'
        }, {
            name : 'timestr',
            mapping : 'timestr'
        }, {
            name : 'state',
            mapping : 'state'
        } ]);
        // 定义选择模式为行选择模式
        var sm = new Ext.grid.CheckboxSelectionModel({
            handleMouseDown : Ext.emptyFn
        }); // 将鼠标按下事件置空
        // 定义列模式(行号和列头)
        cm = new Ext.grid.ColumnModel(
                [
                        new Ext.grid.RowNumberer(),
                        sm,
                        {
                            header : '商户id',
                            dataIndex : 'merchantid',
                            width : 90,
                            hidden : true
                        },
                        {
                            header : '游戏id',
                            dataIndex : 'ltype',
                            width : 90,
                            hidden : true
                        },
                        {
                            header : '商户',
                            dataIndex : 'merchantname',
                            width : 90
                        },
                        {
                            header : '游戏',
                            dataIndex : 'gamename',
                            width : 90
                        },
                        {
                            header : '分流比(%)',
                            dataIndex : 'proportion',
                            width : 90
                        },
                        {
                            header : '每天最大投注金额(元)',
                            dataIndex : 'dayamount',
                            width : 145
                        },
                        {
                            header : '投注时间段',
                            dataIndex : 'timestr',
                            width : 350
                        },
                        {
                            header : '操作',
                            dataIndex : 'state',
                            align : 'center',
                            width : 100,
                            renderer : function(value, metadata, record,
                                    rowIndex, colIndex, store) {
                                var contentId = Ext.id();
                                function createGridButton() {
                                    var operateBtn = new Ext.Button(
                                            {
                                                width : 80,
                                                iconCls : 'select',
                                                handler : function() {
                                                    Ext.Ajax.request({
                                                                url : 'wagerControl__updateState.action',
                                                                params : {
                                                                    'us_merchantid' : record.get('merchantid'),
                                                                    'us_ltype' : record.get('ltype'),
                                                                    'us_state' : record.get('state')
                                                                },
                                                                success : function(response) {
                                                                    if (response.responseText == 'success') {
                                                                        if (operateBtn.text == '暂停') {
                                                                            operateBtn.setText('恢复');
                                                                            grid.getView().getRow(rowIndex).style.backgroundColor = '#1E78B4';// 背景颜色
                                                                        } else {
                                                                            operateBtn.setText('暂停');
                                                                            grid.getView().getRow(rowIndex).style.backgroundColor = 'white';// 背景颜色
                                                                        }
                                                                    } else {
                                                                        Ext.Msg.alert('失败',response.responseText);
                                                                    }
                                                                },
                                                                failure : function() {
                                                                    Ext.Msg.alert('失败','操作失败');
                                                                }
                                                            });

                                                }
                                            }).render(document.body, contentId);

                                    if (value == 1) {
                                        operateBtn.setText('暂停');
                                    } else {
                                        operateBtn.setText('恢复');
                                    }
                                    return operateBtn;
                                }
                                var btn = createGridButton.defer(1, this,[ contentId ]);
                                return ('<div id="' + contentId + '"/>');

                            },
                            sortable : false
                        } ]);
        // 定义表格的数据源
        ds = new Ext.data.Store({
            proxy : new Ext.data.HttpProxy({
                url : gridDSURL,
                method : 'POST'
            }),
            reader : new Ext.data.JsonReader({
                root : 'data',
                totalProperty : 'totalCount',
                successProperty : 'success'
            }, recordDef),
            remoteSort : false
        });

        //表格数据加载
        ds.on('load',function(ds, records, o) {
                            var girdcount = 0;
                            ds.each(function(r) {
                                        if (r.get('state') == 0) {
                                            grid.getView().getRow(girdcount).style.backgroundColor = '#1E78B4';//背景颜色 蓝色
                                        } else {
                                            grid.getView().getRow(girdcount).style.backgroundColor = 'white';//背景颜色  白色
                                        }
                                        girdcount = girdcount + 1;
                                    });

                        });

        // 表格整体配置
        var config = {
            border : false,
            pruneModifiedRecords : true,
            store : ds,
            sm : sm,
            cm : cm,
            enableHdMenu : false,
            loadMask : {
                msg : '数据加载中...'
            },
            clicksToEdit : 1,
            stripeRows : true,
            tbar : upTbar,
            listeners : {
                'afteredit' : function(obj) {
                    var _index = ds.indexOf(obj.record);
                    grid.getSelectionModel().selectRow(_index, true);
                }
            }
        };
        grid = new Ext.grid.EditorGridPanel(config);
       
    }

   
   
    /*
     * 创建工具条按钮
     */
    function createToolbar() {
        upTbar = [];// 上面的工具条
        // 查询
        searchBtn = new Ext.Button({
            text : '查询',
            width : 80,
            iconCls : 'select',
            handler : search
        });
        // 添加
        addBtn = {
            text : '添加',
            width : 80,
            handler : function () {            
                validPwd('addmethod');      
                }
        };
        // 删除
        deleteBtn = {
            text : '删除',
            width : 80,
            handler : function () {            
                validPwd('deletemethod');      
                }
        };
   
        // 修改
        updateBtn = {
            text : '修改',
            width : 80,
            handler : function () {            
                validPwd('updatemethod');      
                }
        };
        upTbar.push(searchBtn, '-',updateBtn, '-',addBtn, '-',deleteBtn, '-');
    }

    /*--------------------功能方法--------------------*/
    // 查询所有方法
    function search() {
        ds.removeAll();
        ds.baseParams = {
        };
        ds.load({
            params : {
                start : 0,
                limit : pageSize
            }
        });
    }
   
    //验证密码
    function validPwd(data){
        var pwdForm= new Ext.form.FormPanel( {
            height:120,
            labelWidth : 80,// 标签宽度
            labelSeparator : ':',// 分隔符
            bodyStyle : 'padding:25 5 5 30',// 表单边距
            buttonAlign:'center',
            frame : true,
            items : [{
                id : 'password',
                xtype : 'textfield',
                allowBlank : false,
                validateOnBlur : false,
                width:100,
                vtype : 'alphanum',
                fieldLabel : '请输入密码',
                blankText : '密码不能为空!',
                inputType : 'password',
                name : 'password'
            } ],
            buttons : [ {
                text : '提交',
                handler : function(){
                    if (pwdForm.getForm().isValid()==false) {
                       
                        Ext.Msg.show({
                                title : '提示',
                                msg : '无法提交,请检查输入项!',
                                buttons : Ext.MessageBox.OK,
                                icon : Ext.Msg.INFO
                        });
                        return;   
                    }
                    if(operatorpwd==''){
                        pwdWindow.close();
                        Ext.Msg.confirm('失败提示','你没有登录,请重新登录!',
                                  function(btn){
                                    if(btn=='yes'){
                                        window.location.href='/GenLotWBOS/index.jsp';//要跳转
                                    }
                                  },this);
                       
                       
                    }
                   
                        if(pwdForm.getForm().findField('password').getValue()==''||pwdForm.getForm().findField('password').getValue()==operatorpwd)    {

                        if(data=='addmethod'){
                            pwdWindow.close();
                            addmethod();
                        }else if(data=='deletemethod'){
                            pwdWindow.close();
                            deletemethod();
                        }else if(data='updatemethod'){
                            pwdWindow.close();
                            updatemethod();
                        }else{
                            pwdWindow.close();
                            Ext.Msg.alert('失败','操作有误');
                        }
                        }else{
                            Ext.Msg.alert('失败','密码错误');
                        }
                }
            }, {
                text : '取消',
                handler : function() {
                    pwdWindow.close();
                }
            } ]
        });
        var pwdWindow = new Ext.Window({
            title : '此操作存在风险,请输入密码后谨慎操作!',
            width : 290,
            resizable : false,
            autoHeight : true,
            modal : true,
            closeAction : 'close',
            items : [pwdForm]
        });
        pwdWindow.show();
       
       
    }
   

    // 第一 分流比的值
    Ext.ux.SliderTip = Ext.extend(Ext.Tip, {
        minWidth : 10,
        offsets : [ 0, -10 ],
        init : function(slider) {
            slider.on('dragstart', this.onSlide, this);
            slider.on('drag', this.onSlide, this);
            slider.on('dragend', this.hide, this);
            slider.on('destroy', this.destroy, this);
        },
        onSlide : function(slider) {
            this.show();
            this.body.update(this.getText(slider));
            this.doAutoWidth();
            this.el.alignTo(slider.thumb, 'b-t?', this.offsets);
        },
        getText : function(slider) {
            return slider.getValue();
        }
    });
    // 添加方法
    function addmethod() {
        var merchantDS = new Ext.data.Store({
            proxy : new Ext.data.HttpProxy({
                'url' : 'business__loadBusiness.action',
                'method' : 'post'
            }),
            reader : new Ext.data.JsonReader({}, [ {
                name : 'value'
            }, {
                name : 'text'
            } ])
        });

        var gamesDS = new Ext.data.Store({
            proxy : new Ext.data.HttpProxy({
                'url' : 'gameinfo__listGames.action',
                'method' : 'post'
            }),
            reader : new Ext.data.JsonReader({}, [ {
                name : 'value'
            }, {
                name : 'text'
            } ])
        });
        var tip = new Ext.ux.SliderTip({
            getText : function(slider) {
                return String.format('<b>{0}%</b>', slider.getValue());
            }
        });

        var a_dayDS = new Ext.data.SimpleStore({
            fields : [ 'value', 'text' ],
            data : [ [ '0', '每日' ] ]
        });
        var a_timestrStore = new Ext.data.SimpleStore({
            fields : [ 'timestrtext' ],
            data : []
        });
        var a_bettimestrStore = new Ext.data.SimpleStore({
            fields : [ 'betday', 'bettimestrtext' ],
            data : []
        });
        var judgeDay='3';// 判断周期 0: 每日、 1:星期几、 3:每日或星期几
        var addfrom = new Ext.FormPanel(
                {
                    labelAlign : 'right',
                    labelWidth : 105,
                    bodyStyle : 'padding:0 0 0 0',// 表单边距
                    border : false,
                    baseCls : 'x-plain',
                    items : [

                    {
                        layout : 'table',
                        layoutConfig : {
                            columns : 2
                        },
                        items : [{
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    editable : false,
                                    baseCls : 'x-plain',
                                    items : [ {id : 'a_merchant',
                                        xtype : 'combo',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        fieldLabel : '商户',
                                        blankText : '商户不能为空!',
                                        name : 'a_merchant',
                                        store : merchantDS,
                                        mode : 'remote',
                                        width : 175,
                                        value:'请选择商户……',
                                        triggerAction : 'all',
                                        valueField : 'value',
                                        displayField : 'text'
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_gamename',
                                        xtype : 'combo',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        fieldLabel : '游戏',
                                        blankText : '游戏不能为空!',
                                        name : 'a_gamename',
                                        store :gamesDS,
                                        mode : 'remote',
                                        width : 175,
                                        value:'请选择游戏……',
                                        triggerAction : 'all',
                                        valueField : 'value',
                                        displayField : 'text'
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_proportion',
                                        xtype : 'slider',
                                        minValue: 0,
                                        maxValue: 100,
                                        width: 175,
                                        increment: 1,
                                        plugins: tip , 
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        fieldLabel : '分流比',
                                        name : 'a_proportion'
                                       
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_dayamount',
                                        xtype : 'textfield',
                                        regex:/^[0-9]{0,9}$/,
                                        regexText:'格式不正确',
                                        width: 175,
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        fieldLabel : '每天最大投注金额',
                                        blankText : '每天最大投注金额不能为空!',
                                        vtype : 'alphanum',
                                        name : 'a_dayamount'
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_daytype',
                                        xtype : 'radiogroup',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        fieldLabel : '周期类型',
                                        name : 'a_daytype',
                                        value:0,
                                        items : [ {
                                            boxLabel : '按天',
                                            name : 'daytype',
                                            inputValue : 0,
                                            checked : true
                                        }, {
                                            boxLabel : '按周',
                                            name : 'daytype',
                                            inputValue : 1
                                        } ],
                                        listeners : {
                                            'change' : function() {
                                                var radio = Ext.getCmp('a_daytype').getValue().inputValue;
                                                var store =  Ext.getCmp('a_day').store;
                                                if(radio == 0){
                                                    store.removeAll();
                                                     var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                {name: 'text', type: 'string'}
                                                                                            ]);
                                                     store.addSorted(new daytypeRecord({  
                                                           value: '0',  
                                                           text: '每日'
                                                        }));
                                                     if( Ext.getCmp('a_day').getValue()!=0){
                                                         Ext.getCmp('a_day').setValue('0');
                                                     }
                                                }else{
                                                    store.removeAll();
                                                     var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                {name: 'text', type: 'string'}
                                                                                            ]);
                                                     store.addSorted([
                                                            new daytypeRecord({
                                                                value : '7',
                                                                text : '星期日'
                                                            }),
                                                            new daytypeRecord({
                                                                value : '6',
                                                                text : '星期六'
                                                            }),
                                                            new daytypeRecord({
                                                                value : '5',
                                                                text : '星期五'
                                                            }),
                                                            new daytypeRecord({
                                                                value : '4',
                                                                text : '星期四'
                                                            }),
                                                            new daytypeRecord({
                                                                value : '3',
                                                                text : '星期三'
                                                            }),
                                                            new daytypeRecord({
                                                                value : '2',
                                                                text : '星期二'
                                                            }),
                                                            new daytypeRecord({
                                                                 value : '1',
                                                                text : '星期一'
                                                            })
                                                            ]
                                                     ); 
                                                     if( Ext.getCmp('a_day').getValue()==0){
                                                         Ext.getCmp('a_day').setValue('1');
                                                     }
                                                    }
                                            }
                                        }
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_day',
                                        xtype : 'combo',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 175,
                                        fieldLabel : '选择周期',
                                        blankText : '周期不能为空!',
                                        name : 'a_day',
                                        value:'0',
                                        store: a_dayDS,
                                        mode: 'local',
                                        triggerAction: 'all',
                                        valueField: 'value',
                                        displayField: 'text'
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_starttime',
                                        xtype : 'textfield',
                                        regex:/^([0-1][0-9]|2[0-3]):([0-5][0-9])$/,
                                        regexText:'格式不正确',
                                        emptyText : '格式如:00:00',
                                        width: 175,
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        fieldLabel : '输入开始时间',
                                        blankText : '开始时间不能为空!',
                                        name : 'a_starttime'
                                    },{
                                        id : 'a_endtime',
                                        xtype : 'textfield',
                                        regex:/^([0-1][0-9]|2[0-3]):([0-5][0-9])$/,


                                        regexText:'格式不正确',
                                        emptyText : '格式如:00:00',
                                        width: 175,
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        fieldLabel : '输入结束时间',
                                        blankText : '结束时间不能为空!',
                                        name : 'a_endtime'
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_addtimebutton',
                                        xtype : 'button',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 110,
                                        fieldLabel : '添加时间段',
                                        text : '添加到时间段',
                                        name : 'a_addtimebutton',
                                        handler : function () {
                                            if (addfrom.getForm().findField('a_starttime').isValid()==false||addfrom.getForm().findField('a_endtime').isValid()==false) {
                                               
                                                Ext.Msg.show({
                                                        title : '提示',
                                                        msg : '无法提交,请检查输入项!',
                                                        buttons : Ext.MessageBox.OK,
                                                        icon : Ext.Msg.INFO
                                                });
                                                return;   
                                            }
                                           
                                           
                                            if((addfrom.getForm().findField('a_endtime').getValue())<(addfrom.getForm().findField('a_starttime').getValue())){
                                                Ext.Msg.alert('添加时间段失败', '结束时间小于开始时间!');
                                            }else{
                                                    var timestrs=addfrom.getForm().findField('a_starttime').getValue()+'-'+addfrom.getForm().findField('a_endtime').getValue();
                                                    var Ext_record=Ext.data.Record.create([
                                                                                           {name:'timestrtext',type:'string'}
                                                                                           ]);
                                                    //判断时间段是否已经选择
                                                    var bool=true;
                                                    a_timestrStore.each(function(record){
                                                        tt=record.data.timestrtext;
                                                        if(tt==timestrs){
                                                        bool=false;
                                                        Ext.Msg.alert('提示', '该时间段已选择!');
                                                        }
                                                        //判断时间是否在已选时间段之内
                                                        var ttArr=tt.split('-');
                                                        if((ttArr[0]<addfrom.getForm().findField('a_starttime').getValue()&&addfrom.getForm().findField('a_starttime').getValue()<ttArr[1])||
                                                                (ttArr[0]<addfrom.getForm().findField('a_endtime').getValue()&&addfrom.getForm().findField('a_endtime').getValue()<ttArr[1])||
                                                                (ttArr[0]>addfrom.getForm().findField('a_starttime').getValue()&&addfrom.getForm().findField('a_endtime').getValue()>ttArr[0])||
                                                                (ttArr[1]>addfrom.getForm().findField('a_starttime').getValue()&&addfrom.getForm().findField('a_endtime').getValue()>ttArr[1])){
                                                            bool=false;
                                                            Ext.Msg.alert('提示', '该时间段和已选择的时间段有交叉!');
                                                        }
                                                       
                                                    });
                                                    if(bool){
                                                        var records=Ext.getCmp('a_timestrtext').getSelectionModel().getSelections();
                                                        if(records!=null){
                                                        a_timestrStore.remove(records);
                                                        }
                                                    a_timestrStore.addSorted(new Ext_record({
                                                        timestrtext:timestrs
                                                    }));
                                                    addfrom.getForm().findField('a_starttime').reset();
                                                    addfrom.getForm().findField('a_endtime').reset();
                                                }
                                            }

                                        }

                                    } ]
                                }, {
                                    colspan : 1,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_timestrtext',
                                        xtype : 'grid',
                                        fieldLabel : '时间段',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 175,
                                        height :80,
                                        name : 'a_timestrtext',
                                        store: a_timestrStore,
                                        multiSelect: true,
                                        columns: [{
                                            width: 170,
                                            dataIndex: 'timestrtext'
                                        }],
                                        listeners : {
                                            'rowclick' : function(grid,index,e) {
                                                var gridtimestrs=grid.getStore().getAt(index).get('timestrtext');
                                                var gridtimestrsArr=gridtimestrs.split('-');
                                                addfrom.getForm().findField('a_starttime').reset();
                                                addfrom.getForm().findField('a_starttime').setValue(gridtimestrsArr[0]);
                                                addfrom.getForm().findField('a_endtime').reset();
                                                addfrom.getForm().findField('a_endtime').setValue(gridtimestrsArr[1]);
                                               
                                            }
                                        }
                                    } ]
                                }, {
                                    colspan : 1,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_removetimebutton',
                                        xtype : 'button',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 100,
                                        text : '删除时间段',
                                        name : 'a_removetimebutton',
                                        handler : function () {
                                            var records=Ext.getCmp('a_timestrtext').getSelectionModel().getSelections();
                                            a_timestrStore.remove(records);
                                        }
                                    },{id : 'a_cleartimebutton',
                                        xtype : 'button',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 100,
                                        text : '清空时间段',
                                        name : 'a_cleartimebutton',
                                        handler : function () {
                                            a_timestrStore.removeAll();
                                        }   
                                    } ]
                                }, {
                                    colspan : 2,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {id : 'a_addbettimebutton',
                                        xtype : 'button',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 110,
                                        fieldLabel : '添加投注时间段',
                                        text : '添加到投注时间段',
                                        name : 'a_addbettimebutton',
                                        handler : function () {
                                           
                                            var Ext_record = Ext.data.Record.create([
                                                                                     {name:'betday',type:'string'},
                                                                                     {name : 'bettimestrtext',type : 'string'}
                                                                                     ]);
                                            var daytype=''; 
                                            if(Ext.getCmp('a_day').value==1){
                                                daytype='星期一';
                                            }else if(Ext.getCmp('a_day').value==2){
                                                daytype='星期二';
                                            }else if(Ext.getCmp('a_day').value==3){
                                                daytype='星期三';
                                            }else if(Ext.getCmp('a_day').value==4){
                                                daytype='星期四';
                                            }else if(Ext.getCmp('a_day').value==5){
                                                daytype='星期五';
                                            }else if(Ext.getCmp('a_day').value==6){
                                                daytype='星期六';
                                            }else if(Ext.getCmp('a_day').value==7){
                                                daytype='星期日';
                                            }else{
                                                daytype='每日';
                                            }
                                           
                                            var bettimestrs='';
                                            a_timestrStore.each(function(record){
                                                if(record.data.timestrtext!=null&&record.data.timestrtext!=''){
                                                    bettimestrs+=record.data.timestrtext+' ';
                                                }
                                            });
                                           
                                           
                                            //判断时间段是否已经选择
                                            var bool=true;
                                            if(bettimestrs==''){
                                                bool=false;
                                                Ext.Msg.alert('提示', '请添加时间!');
                                            }
                                            a_bettimestrStore.each(function(record){
                                                bd=record.data.betday;
                                                tt=record.data.bettimestrtext;
                                                    if(bd==daytype){
                                                        bool=false;   
                                                        Ext.Msg.confirm('提示','你已选择该日的投注时间段,确认要覆盖吗?',
                                                                  function(btn){
                                                                    if(btn=='yes'){
                                                                        a_bettimestrStore.remove(record);
                                                                        bool=true;   
                                                                        //判断 周期类型
                                                                        if(judgeDay=='0'){
                                                                            if(Ext.getCmp('a_day').value!='0'){
                                                                                bool=false;
                                                                                Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"每日"添加投注时间段(如果想按"星期"添加投注时间段,请先清空)!');
                                                                            }
                                                                            if(bool){
                                                                                a_bettimestrStore.addSorted(new Ext_record(
                                                                                        {
                                                                                            betday:daytype,
                                                                                            bettimestrtext : bettimestrs
                                                                                        }));
                                                                                a_timestrStore.removeAll();
                                                                            }
                                                                        }else if(judgeDay=='1'){
                                                                            if (Ext.getCmp('a_day').value == '0') {
                                                                                bool=false;
                                                                                Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"星期"添加投注时间段(如果想按"每日"添加投注时间段,请先清空)!');
                                                                            }
                                                                            if(bool){
                                                                                a_bettimestrStore.addSorted(new Ext_record(
                                                                                        {
                                                                                            betday:daytype,
                                                                                            bettimestrtext : bettimestrs
                                                                                        }));
                                                                                a_timestrStore.removeAll();
                                                                            }
                                                                        }else{
                                                                            if (Ext.getCmp('a_day').value == '0') {
                                                                                judgeDay='0';
                                                                            }else{
                                                                                judgeDay='1';   
                                                                            }
                                                                            if(bool){
                                                                                a_bettimestrStore.addSorted(new Ext_record(
                                                                                        {
                                                                                            betday:daytype,
                                                                                            bettimestrtext : bettimestrs
                                                                                        }));
                                                                                a_timestrStore.removeAll();
                                                                            }
                                                                        }
                                                                    }else{
                                                                    }
                                                                  },this);
                                                }
                                            });
                                            if(bool){
                                            //判断 周期类型
                                            if(judgeDay=='0'){
                                                if(Ext.getCmp('a_day').value!='0'){
                                                    bool=false;
                                                    Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"每日"添加投注时间段(如果想按"星期"添加投注时间段,请先清空)!');
                                                }
                                                if(bool){
                                                    a_bettimestrStore.addSorted(new Ext_record(
                                                            {
                                                                betday:daytype,
                                                                bettimestrtext : bettimestrs
                                                            }));
                                                    a_timestrStore.removeAll();
                                                }
                                            }else if(judgeDay=='1'){
                                                if (Ext.getCmp('a_day').value == '0') {
                                                    bool=false;
                                                    Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"星期"添加投注时间段(如果想按"每日"添加投注时间段,请先清空)!');
                                                }
                                                if(bool){
                                                    a_bettimestrStore.addSorted(new Ext_record(
                                                            {
                                                                betday:daytype,
                                                                bettimestrtext : bettimestrs
                                                            }));
                                                    a_timestrStore.removeAll();
                                                }
                                            }else{
                                                if (Ext.getCmp('a_day').value == '0') {
                                                    judgeDay='0';
                                                }else{
                                                    judgeDay='1';   
                                                }
                                                if(bool){
                                                    a_bettimestrStore.addSorted(new Ext_record(
                                                            {
                                                                betday:daytype,
                                                                bettimestrtext : bettimestrs
                                                            }));
                                                    a_timestrStore.removeAll();
                                                }
                                            }
                                            }
                                        }   
                                   
                                    } ]
                                }, {
                                    colspan : 1,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                                id : 'a_bettimestrtext',
                                                xtype : 'grid',
                                                fieldLabel : '投注时间段',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                reserveScrollOffset: true,
                                                width: 175,
                                                height :100,
                                                name : 'a_bettimestrtext',
                                                store:a_bettimestrStore,
                                                multiSelect: true,
                                                columns: [{
                                                         header: '周期',
                                                         width: 50,
                                                         dataIndex: 'betday'
                                                    },{
                                                         header: '时间段',
                                                         width: 1000,
                                                         dataIndex: 'bettimestrtext'
                                                    }],
                                                    listeners : {
                                                        'rowclick' : function(grid,index,e) {
                                                            a_timestrStore.removeAll();
                                                            var Ext_record=Ext.data.Record.create([
                                                                                                   {name:'timestrtext',type:'string'}
                                                                                                   ]);
                                                            var gridtimestrs=grid.getStore().getAt(index).get('bettimestrtext');
                                                            var gridday=grid.getStore().getAt(index).get('betday');
                                                            var gridtimestrsArr=gridtimestrs.split(' ');
                                                            //向 时间段添加数据
                                                            for (var i = 0; i <gridtimestrsArr.length-1; i++) {
                                                            a_timestrStore.addSorted(new Ext_record({
                                                                timestrtext:gridtimestrsArr[i]
                                                            }));
                                                            }
                                                            //设置选择 周期类型 周期
                                                            var store =  Ext.getCmp('a_day').store;
                                                            if(gridday=='每日'){
                                                                Ext.getCmp('a_daytype').setValue(0);
                                                                    store.removeAll();
                                                                     var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                                {name: 'text', type: 'string'}
                                                                                                            ]);
                                                                     store.addSorted(new daytypeRecord({  
                                                                           value: '0',  
                                                                            text: '每日'
                                                                        })); 
                                                                     judgeDay='0';
                                                                     Ext.getCmp('a_day').setValue('0');
                                                                }else{
                                                                    Ext.getCmp('a_daytype').setValue(1);
                                                                    store.removeAll();
                                                                     var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                                {name: 'text', type: 'string'}
                                                                                                            ]);
                                                                     store.addSorted([
                                                                            new daytypeRecord({
                                                                                value : '7',
                                                                                text : '星期日'
                                                                            }),
                                                                            new daytypeRecord({
                                                                                value : '6',
                                                                                text : '星期六'
                                                                            }),
                                                                            new daytypeRecord({
                                                                                value : '5',
                                                                                text : '星期五'
                                                                            }),
                                                                            new daytypeRecord({
                                                                                value : '4',
                                                                                text : '星期四'
                                                                            }),
                                                                            new daytypeRecord({
                                                                                value : '3',
                                                                                text : '星期三'
                                                                            }),
                                                                            new daytypeRecord({
                                                                                value : '2',
                                                                                text : '星期二'
                                                                            }),
                                                                            new daytypeRecord({
                                                                                 value : '1',
                                                                                text : '星期一'
                                                                            })
                                                                            ]
                                                                     );
                                                                     judgeDay='1';
                                                                     if(gridday=='星期日'){
                                                                     Ext.getCmp('a_day').setValue('7');
                                                                     }else if(gridday=='星期六'){
                                                                     Ext.getCmp('a_day').setValue('6');
                                                                     }else if(gridday=='星期五'){
                                                                     Ext.getCmp('a_day').setValue('5');
                                                                     }else if(gridday=='星期四'){
                                                                     Ext.getCmp('a_day').setValue('4');
                                                                     }else if(gridday=='星期三'){
                                                                     Ext.getCmp('a_day').setValue('3');
                                                                     }else if(gridday=='星期二'){
                                                                     Ext.getCmp('a_day').setValue('2');
                                                                     }else{
                                                                     Ext.getCmp('a_day').setValue('1');
                                                                     }
                                                                    }
                                                        }
                                                    }
                                    } ]
                                }, {
                                    colspan : 1,
                                    layout : 'form',
                                    frame : true,
                                    defaultType : 'textfield',
                                    border : false,
                                    baseCls : 'x-plain',
                                    items : [ {
                                        id : 'a_removebettimebutton',
                                        xtype : 'button',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 100,
                                        text : '删除投注时间段',
                                        name : 'a_removebettimebutton',
                                        handler : function () {
                                            var betrecords=Ext.getCmp('a_bettimestrtext').getSelectionModel().getSelections();
                                            a_bettimestrStore.remove(betrecords);
                                            var bo=true;// 判断bettimestrStore是否已经被删除完
                                            a_bettimestrStore.each(function(record){
                                                bo=false;
                                            });
                                            if(bo){
                                                judgeDay='3';
                                            }
                                        }
                                    },{
                                        id : 'a_clearbettimebutton',
                                        xtype : 'button',
                                        allowBlank : false,
                                        validateOnBlur : false,
                                        width: 100,
                                        text : '清空投注时间段',
                                        name : 'a_clearbettimebutton',
                                        handler : function () {
                                            judgeDay='3';
                                            a_bettimestrStore.removeAll();
                                        }
                                       
                                    } ]
                               
                                } ]
                    }

                    ],
                    buttonAlign : 'center',
                    minButtonWidth : 60,
                    buttons : [
                            {
                                text : '提交',
                                handler : function() {
                                    if ( addfrom.getForm().findField('a_dayamount').isValid()==false) {
                                       
                                        Ext.Msg.show({
                                                title : '提示',
                                                msg : '无法提交,请检查输入项!',
                                                buttons : Ext.MessageBox.OK,
                                                icon : Ext.Msg.INFO
                                        });
                                        return;   
                                    }
                                    var timestrs='';
                                    a_bettimestrStore.each(function(record){
                                        timestrs+=record.data.betday+'@'+record.data.bettimestrtext+';';
                                    });
                                    Ext.Ajax.request({
                                                url : 'wagerControl__addTjWagerControl.action',
                                                params : {
                                                    'a_merchant' : addfrom.getForm().findField('a_merchant').getValue(),
                                                    'a_gamename' : addfrom.getForm().findField('a_gamename').getValue(),
                                                    'a_proportion' : Ext.getCmp('a_proportion').value,
                                                    'a_dayamount' : addfrom.getForm().findField('a_dayamount').getValue(),
                                                    'a_timestr' : timestrs==''?null:timestrs
                                                },
                                                success : function(response) {
                                                    if (response.responseText == 'success') {
                                                        judgeDay='3';
                                                        a_timestrStore.removeAll();
                                                        a_bettimestrStore.removeAll();
                                                        Ext.Msg.alert('成功','添加信息成功!');
                                                        search();
                                                        addwin.close();
                                                    } else {
                                                        Ext.Msg.alert('失败',response.responseText);
                                                    }
                                                },
                                                failure : function() {
                                                    Ext.Msg.alert('失败','添加失败');
                                                }
                                            });
                                }
                            }, {
                                text : '重置',
                                handler : function() {
                                    judgeDay='3';
                                    a_timestrStore.removeAll();
                                    a_bettimestrStore.removeAll();
                                    addfrom.form.reset();
                                }
                            }, {
                                text : '取消',
                                handler : function() {
                                    judgeDay='3';
                                    a_timestrStore.removeAll();
                                    a_bettimestrStore.removeAll();
//                                    addfrom.form.reset();
                                    addwin.close();
                                }
                            } ]
                });   
        var     addwin = new Ext.Window({
            title : "添加",
            width : 450,
            resizable : false,
            autoHeight : true,
            modal : true,
            closeAction : 'close',
            items : [ addfrom ]
        });
        addwin.show();
    }
    // 删除方法
    function deletemethod() {
        var d_merchantid;
        var d_ltype;
        // 获取表格数据
        var records = grid.getSelectionModel().getSelections();
        if (records.length > 0) {
                var merchantidltypes='';
                for(var i=0;i<records.length;i++){
                    merchantidltypes+=records[i].get("merchantid")+'&'+records[i].get("ltype")+';';
                }
                Ext.Msg.confirm('确认提示','确定要删除吗?',
                          function(btn){
                            if(btn=='yes'){
                                Ext.Ajax.request({
                                    url : 'wagerControl__deleteTjWagerControl.action',
                                    params : {
                                        'merchantidltypes' : merchantidltypes
                                    },
                                    success : function(response) {
                                        if (response.responseText == 'success') {
                                            Ext.Msg.alert('成功', '删除成功!');
                                            search();
                                        } else {
                                            Ext.Msg.alert('失败', response.responseText);
                                        }
                                    },
                                    failure : function() {
                                        Ext.Msg.alert('失败', '删除失败!');
                                    }
                                });                       
                            }else{
                            }
                          },this);
           
        } else {
            Ext.Msg.alert('信息', '请选择需要删除的选项!');
        }

    }


    // 修改方法
    function updatemethod() {
       var u_tip = new Ext.ux.SliderTip({
            getText : function(slider) {
                return String.format('<b>{0}%</b>', slider.getValue());
            }
        });

        var u_dayDS = new Ext.data.SimpleStore({
            fields : [ 'value', 'text' ],
            data : [ [ '0', '每日' ] ]
        });
        var u_timestrStore = new Ext.data.SimpleStore({
            fields : [ 'timestrtext' ],
            data : []
        });
        var u_bettimestrStore = new Ext.data.SimpleStore({
            fields : [ 'betday', 'bettimestrtext' ],
            data : []
        });
        var u_merchantid;
        var u_ltype;
        var u_merchantname;
        var u_gamename;
        var u_proportion;
        var u_dayamount;
        var u_timestr;
        var judgeDay='3';//判断周期   0: 每日、  1:星期几、  3:每日或星期几
        // 获取表格数据
        var records = grid.getSelectionModel().getSelections();
        if (records.length > 0) {
            if (records.length > 1) {
                Ext.Msg.alert('信息', '请选择一个需要修改的选项!');
            } else {
                u_merchantname = records[0].get("merchantname");
                u_gamename = records[0].get("gamename");
                u_merchantid = records[0].get("merchantid");
                u_ltype = records[0].get("ltype");
                u_proportion = records[0].get("proportion");
                u_dayamount = records[0].get("dayamount");
                u_timestr = records[0].get("timestr");//星期二 9:00-20:00 22:00-23:30|星期三 11:11-12:12|
                var Ext_record = Ext.data.Record.create([
                                                         {name:'betday',type:'string'},
                                                         {name : 'bettimestrtext',type : 'string'}
                                                         ]);
                var st=u_timestr.split('|');
                if(st!=null){
                    if(st[0].split('\t')[0]=='每日'){
                        judgeDay='0';
                    }else{
                        judgeDay='1';
                    }
                }
                for (var i = 0; i <st.length-1; i++) {
                var stArr=st[i].split('\t');
                u_bettimestrStore.addSorted(new Ext_record(
                        {
                            betday:stArr[0],
                            bettimestrtext : stArr[1]+' '
                        }));
                }
                var updateFrom = new Ext.FormPanel(
                        {
                            labelAlign : 'right',
                            labelWidth : 105,
                            bodyStyle : 'padding:0 0 0 0',// 表单边距
                            border : false,
                            baseCls : 'x-plain',
                            items : [
                            {
                                layout : 'table',
                                layoutConfig : {
                                    columns : 2
                                },
                                items : [{
                                            colspan : 2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            editable : false,
                                            baseCls : 'x-plain',
                                            items : [ {id : 'u_merchantname',
                                                xtype : 'textfield',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                disabled:true,
                                                 width: 175,
                                                fieldLabel : '商户',
                                                name : 'u_merchantname',
                                                value : u_merchantname} ]
                                        }, {
                                            colspan : 2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_gamename',
                                                xtype : 'textfield',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                disabled:true,
                                                 width: 175,
                                                fieldLabel : '游戏',
                                                value : u_gamename,
                                                name : 'u_gamename'
                                            } ]
                                        }, {
                                            colspan : 2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_proportion',
                                                xtype : 'slider',
                                                minValue: 0,
                                                maxValue: 100,
                                                width: 175,
                                                increment: 1,
                                                value : u_proportion,
                                                plugins: u_tip , 
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                fieldLabel : '分流比',
                                                name : 'u_proportion'
                                               
                                            } ]
                                        }, {
                                            colspan : 2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_dayamount',
                                                xtype : 'textfield',
                                                regex:/^[0-9]{0,9}$/,
                                                regexText:'格式不正确',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 175,
                                                fieldLabel : '每天最大投注金额',
                                                blankText : '每天最大投注金额不能为空!',
                                                name : 'u_dayamount',
                                                value : u_dayamount
                                            } ]
                                        }, {
                                            colspan : 2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_daytype',
                                                xtype : 'radiogroup',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                fieldLabel : '周期类型',
                                                name : 'u_daytype',
                                                value:0,
                                                items : [ {
                                                    boxLabel : '按天',
                                                    name : 'daytype',
                                                    inputValue : 0,
                                                    checked : true
                                                }, {
                                                    boxLabel : '按周',
                                                    name : 'daytype',
                                                    inputValue : 1
                                                } ],
                                                listeners : {
                                                    'change' : function() {
                                                        var radio = Ext.getCmp('u_daytype').getValue().inputValue;
                                                        var store =  Ext.getCmp('u_day').store;
                                                        if(radio == 0){
                                                            store.removeAll();
                                                             var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                        {name: 'text', type: 'string'}
                                                                                                    ]);
                                                             store.addSorted(new daytypeRecord({  
                                                                   value: '0',  
                                                                    text: '每日'
                                                                })); 
                                                             if( Ext.getCmp('u_day').getValue()!=0){
                                                                 Ext.getCmp('u_day').setValue('0');
                                                             }
                                                        }else{
                                                            store.removeAll();
                                                             var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                        {name: 'text', type: 'string'}
                                                                                                    ]);
                                                             store.addSorted([
                                                                    new daytypeRecord({
                                                                        value : '7',
                                                                        text : '星期日'
                                                                    }),
                                                                    new daytypeRecord({
                                                                        value : '6',
                                                                        text : '星期六'
                                                                    }),
                                                                    new daytypeRecord({
                                                                        value : '5',
                                                                        text : '星期五'
                                                                    }),
                                                                    new daytypeRecord({
                                                                        value : '4',
                                                                        text : '星期四'
                                                                    }),
                                                                    new daytypeRecord({
                                                                        value : '3',
                                                                        text : '星期三'
                                                                    }),
                                                                    new daytypeRecord({
                                                                        value : '2',
                                                                        text : '星期二'
                                                                    }),
                                                                    new daytypeRecord({
                                                                         value : '1',
                                                                        text : '星期一'
                                                                    })
                                                                    ]
                                                             ); 
                                                             if( Ext.getCmp('u_day').getValue()==0){
                                                                 Ext.getCmp('u_day').setValue('1');
                                                             }
                                                            }
                                                    }
                                                }
                                            } ]
                                        }, {
                                            colspan : 2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_day',
                                                xtype : 'combo',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 175,
                                                fieldLabel : '选择周期',
                                                blankText : '周期不能为空!',
                                                name : 'u_day',
                                                value:'0',
                                                store: u_dayDS,
                                                mode: 'local',
                                                triggerAction: 'all',
                                                valueField: 'value',
                                                displayField: 'text'
                                            } ]
                                        }, {
                                            colspan :2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_starttime',
                                                xtype : 'textfield',
                                                regex:/^([0-1][0-9]|2[0-3]):([0-5][0-9])$/,
                                                regexText:'格式不正确',
                                                emptyText : '格式如:00:00',
                                                width: 175,
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                fieldLabel : '输入开始时间',
                                                blankText : '开始时间不能为空!',
                                                name : 'u_starttime'
                                            },{
                                                id : 'u_endtime',
                                                xtype : 'textfield',
                                                regex:/^([0-1][0-9]|2[0-3]):([0-5][0-9])$/,
                                                regexText:'格式不正确',
                                                emptyText : '格式如:00:00',
                                                width: 175,
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                fieldLabel : '输入结束时间',
                                                blankText : '结束时间不能为空!',
                                                name : 'u_endtime'
                                            } ]
                                        }, {
                                            colspan :2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_addtimebutton',
                                                xtype : 'button',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 110,
                                                fieldLabel : '添加时间段',
                                                text : '添加到时间段',
                                                name : 'u_addtimebutton',
                                                handler : function () {
                                                   
                                                   
                                                    if (updateFrom.getForm().findField('u_starttime').isValid()==false||updateFrom.getForm().findField('u_endtime').isValid()==false) {
                                                       
                                                        Ext.Msg.show({
                                                                title : '提示',
                                                                msg : '无法提交,请检查输入项!',
                                                                buttons : Ext.MessageBox.OK,
                                                                icon : Ext.Msg.INFO
                                                        });
                                                        return;   
                                                    }
                                                   
                                                   
                                                    if((updateFrom.getForm().findField('u_endtime').getValue())<(updateFrom.getForm().findField('u_starttime').getValue())){
                                                        Ext.Msg.alert('添加时间段失败', '结束时间小于开始时间!');
                                                    }else{
                                                            var timestrs=updateFrom.getForm().findField('u_starttime').getValue()+'-'+updateFrom.getForm().findField('u_endtime').getValue();
                                                            var Ext_record=Ext.data.Record.create([
                                                                                                   {name:'timestrtext',type:'string'}
                                                                                                   ]);
                                                            //判断时间段是否已经选择
                                                            var bool=true;
                                                            u_timestrStore.each(function(record){
                                                                tt=record.data.timestrtext;
                                                                if(tt==timestrs){
                                                                bool=false;
                                                                Ext.Msg.alert('提示', '该时间段已选择!');
                                                                }
                                                               
                                                                //判断时间是否在已选时间段之内
                                                                var ttArr=tt.split('-');
                                                                if((ttArr[0]<updateFrom.getForm().findField('u_starttime').getValue()&&updateFrom.getForm().findField('u_starttime').getValue()<ttArr[1])||
                                                                        (ttArr[0]<updateFrom.getForm().findField('u_endtime').getValue()&&updateFrom.getForm().findField('u_endtime').getValue()<ttArr[1])||
                                                                        (ttArr[0]>updateFrom.getForm().findField('u_starttime').getValue()&&updateFrom.getForm().findField('u_endtime').getValue()>ttArr[0])||
                                                                        (ttArr[1]>updateFrom.getForm().findField('u_starttime').getValue()&&updateFrom.getForm().findField('u_endtime').getValue()>ttArr[1])){
                                                                    bool=false;
                                                                    Ext.Msg.alert('提示', '该时间段和已选择的时间段有交叉!');
                                                                }
                                                               
                                                            });
                                                            if(bool){
                                                                var records=Ext.getCmp('u_timestrtext').getSelectionModel().getSelections();
                                                                if(records!=null){
                                                                    u_timestrStore.remove(records);
                                                                }
                                                                u_timestrStore.addSorted(new Ext_record({
                                                                timestrtext:timestrs
                                                            }));
                                                            updateFrom.getForm().findField('u_starttime').reset();
                                                            updateFrom.getForm().findField('u_endtime').reset();
                                                        }
                                                        }

                                                }

                                            } ]
                                        }, {
                                            colspan : 1,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_timestrtext',
                                                xtype : 'grid',
                                                fieldLabel : '时间段',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 175,
                                                height :80,
                                                name : 'u_timestrtext',
                                                store: u_timestrStore,
                                                multiSelect: true,
                                                columns: [{
                                                    width: 170,
                                                    dataIndex: 'timestrtext'
                                                }],
                                                listeners : {
                                                    'rowclick' : function(grid,index,e) {
                                                        var gridtimestrs=grid.getStore().getAt(index).get('timestrtext');
                                                        var gridtimestrsArr=gridtimestrs.split('-');
                                                        updateFrom.getForm().findField('u_starttime').reset();
                                                        updateFrom.getForm().findField('u_starttime').setValue(gridtimestrsArr[0]);
                                                        updateFrom.getForm().findField('u_endtime').reset();
                                                        updateFrom.getForm().findField('u_endtime').setValue(gridtimestrsArr[1]);
                                                    }
                                                    }
                                            } ]
                                        }, {
                                            colspan : 1,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_removetimebutton',
                                                xtype : 'button',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 100,
                                                text : '删除时间段',
                                                name : 'u_removetimebutton',
                                                handler : function () {
                                                    var records=Ext.getCmp('u_timestrtext').getSelectionModel().getSelections();
                                                    u_timestrStore.remove(records);
                                                }
                                            },{id : 'u_cleartimebutton',
                                                xtype : 'button',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 100,
                                                text : '清空时间段',
                                                name : 'u_cleartimebutton',
                                                handler : function () {
                                                    u_timestrStore.removeAll();
                                                }   
                                            } ]
                                        }, {
                                            colspan : 2,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [{id : 'u_addbettimebutton',
                                                xtype : 'button',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 110,
                                                fieldLabel : '添加投注时间段',
                                                text : '添加到投注时间段',
                                                name : 'u_addbettimebutton',
                                                handler : function () {
                                                   
                                                    var Ext_record = Ext.data.Record.create([
                                                                                             {name:'betday',type:'string'},
                                                                                             {name : 'bettimestrtext',type : 'string'}
                                                                                             ]);
                                                    var daytype=''; 
                                                    if(Ext.getCmp('u_day').value==1){
                                                        daytype='星期一';
                                                    }else if(Ext.getCmp('u_day').value==2){
                                                        daytype='星期二';
                                                    }else if(Ext.getCmp('u_day').value==3){
                                                        daytype='星期三';
                                                    }else if(Ext.getCmp('u_day').value==4){
                                                        daytype='星期四';
                                                    }else if(Ext.getCmp('u_day').value==5){
                                                        daytype='星期五';
                                                    }else if(Ext.getCmp('u_day').value==6){
                                                        daytype='星期六';
                                                    }else if(Ext.getCmp('u_day').value==7){
                                                        daytype='星期日';
                                                    }else{
                                                        daytype='每日';
                                                    }
                                                   
                                                    var bettimestrs='';
                                                    u_timestrStore.each(function(record){
                                                        if(record.data.timestrtext!=null&&record.data.timestrtext!=''){
                                                            bettimestrs+=record.data.timestrtext+' ';
                                                        }
                                                    });
                                                   
                                                   
                                                    //判断时间段是否已经选择
                                                    var bool=true;
                                                    if(bettimestrs==''){
                                                        bool=false;
                                                        Ext.Msg.alert('提示', '请添加时间段!');
                                                    }
                                                    u_bettimestrStore.each(function(record){
                                                        bd=record.data.betday;
                                                        tt=record.data.bettimestrtext;
                                                        if(bd==daytype){
                                                            bool=false;
                                                            Ext.Msg.confirm('提示','你已选择该日的投注时间段,确认要覆盖吗?',
                                                                      function(btn){
                                                                        if(btn=='yes'){
                                                                            u_bettimestrStore.remove(record);
                                                                            bool=true;   
                                                                            //判断 周期类型
                                                                            if(judgeDay=='0'){
                                                                                if(Ext.getCmp('u_day').value!='0'){
                                                                                    bool=false;
                                                                                    Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"每日"添加投注时间段(如果想按"星期"添加投注时间段,请先清空)!');
                                                                                }
                                                                                if(bool){
                                                                                    u_bettimestrStore.addSorted(new Ext_record(
                                                                                            {
                                                                                                betday:daytype,
                                                                                                bettimestrtext : bettimestrs
                                                                                            }));
                                                                                    u_timestrStore.removeAll();
                                                                                }
                                                                            }else if(judgeDay=='1'){
                                                                                if (Ext.getCmp('u_day').value == '0') {
                                                                                    bool=false;
                                                                                    Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"星期"添加投注时间段(如果想按"每日"添加投注时间段,请先清空)!');
                                                                                }
                                                                                if(bool){
                                                                                    u_bettimestrStore.addSorted(new Ext_record(
                                                                                            {
                                                                                                betday:daytype,
                                                                                                bettimestrtext : bettimestrs
                                                                                            }));
                                                                                    u_timestrStore.removeAll();
                                                                                }
                                                                            }else{
                                                                                if (Ext.getCmp('u_day').value == '0') {
                                                                                    judgeDay='0';
                                                                                }else{
                                                                                    judgeDay='1';   
                                                                                }
                                                                                if(bool){
                                                                                    u_bettimestrStore.addSorted(new Ext_record(
                                                                                            {
                                                                                                betday:daytype,
                                                                                                bettimestrtext : bettimestrs
                                                                                            }));
                                                                                    u_timestrStore.removeAll();
                                                                                }
                                                                            }
                                                                        }else{
                                                                           
                                                                        }
                                                                      },this);
                                                        }
                                                    });
                                                    if(bool){
                                                    //判断 周期类型
                                                    if(judgeDay=='0'){
                                                        if(Ext.getCmp('u_day').value!='0'){
                                                            bool=false;
                                                            Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"每日"添加投注时间段(如果想按"星期"添加投注时间段,请先清空)!');
                                                        }
                                                        if(bool){
                                                            u_bettimestrStore.addSorted(new Ext_record(
                                                                    {
                                                                        betday:daytype,
                                                                        bettimestrtext : bettimestrs
                                                                    }));
                                                            u_timestrStore.removeAll();
                                                        }
                                                    }else if(judgeDay=='1'){
                                                        if (Ext.getCmp('u_day').value == '0') {
                                                            bool=false;
                                                            Ext.Msg.alert('添加投注时间段失败', '周期类型已选择按"星期"添加投注时间段(如果想按"每日"添加投注时间段,请先清空)!');
                                                        }
                                                        if(bool){
                                                            u_bettimestrStore.addSorted(new Ext_record(
                                                                    {
                                                                        betday:daytype,
                                                                        bettimestrtext : bettimestrs
                                                                    }));
                                                            u_timestrStore.removeAll();
                                                        }
                                                    }else{
                                                        if (Ext.getCmp('u_day').value == '0') {
                                                            judgeDay='0';
                                                        }else{
                                                            judgeDay='1';   
                                                        }
                                                        if(bool){
                                                            u_bettimestrStore.addSorted(new Ext_record(
                                                                    {
                                                                        betday:daytype,
                                                                        bettimestrtext : bettimestrs
                                                                    }));
                                                            u_timestrStore.removeAll();
                                                        }
                                                    }
                                                    }
                                                }   
                                           
                                            } ]
                                        }, {
                                            colspan : 1,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                        id : 'u_bettimestrtext',
                                                        xtype : 'grid',
                                                        fieldLabel : '投注时间段',
                                                        allowBlank : false,
                                                        validateOnBlur : false,
                                                        width: 175,
                                                        height :100,
                                                        name : 'u_bettimestrtext',
                                                        store:u_bettimestrStore,
                                                            multiSelect: true,
                                                            columns: [{
                                                                 header: '周期',
                                                                 width: 50,
                                                                dataIndex: 'betday'
                                                            },{
                                                                 header: '时间段',
                                                                 width: 1000,
                                                                dataIndex: 'bettimestrtext'
                                                            }],
                                                            listeners : {
                                                                'rowclick' : function(grid,index,e) {
                                                                    u_timestrStore.removeAll();
                                                                    var Ext_record=Ext.data.Record.create([
                                                                                                           {name:'timestrtext',type:'string'}
                                                                                                           ]);
                                                                    var gridtimestrs=grid.getStore().getAt(index).get('bettimestrtext');
                                                                    var gridday=grid.getStore().getAt(index).get('betday');
                                                                    var gridtimestrsArr=gridtimestrs.split(' ');
                                                                    //想 时间段添加数据
                                                                    for (var i = 0; i <gridtimestrsArr.length-1; i++) {
                                                                        u_timestrStore.addSorted(new Ext_record({
                                                                        timestrtext:gridtimestrsArr[i]
                                                                    }));
                                                                    }
                                                                    //设置选择周期 周期类型
                                                                    var store =  Ext.getCmp('u_day').store;
                                                                    if(gridday=='每日'){
                                                                        Ext.getCmp('u_daytype').setValue(0);
                                                                            store.removeAll();
                                                                             var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                                        {name: 'text', type: 'string'}
                                                                                                                    ]);
                                                                             store.addSorted(new daytypeRecord({  
                                                                                   value: '0',  
                                                                                    text: '每日'
                                                                                })); 
                                                                             judgeDay='0';
                                                                             Ext.getCmp('u_day').setValue('0');
                                                                        }else{
                                                                            Ext.getCmp('u_daytype').setValue(1);
                                                                            store.removeAll();
                                                                             var daytypeRecord = Ext.data.Record.create([{name:'value', type: 'string'},
                                                                                                                        {name: 'text', type: 'string'}
                                                                                                                    ]);
                                                                             store.addSorted([
                                                                                    new daytypeRecord({
                                                                                        value : '7',
                                                                                        text : '星期日'
                                                                                    }),
                                                                                    new daytypeRecord({
                                                                                        value : '6',
                                                                                        text : '星期六'
                                                                                    }),
                                                                                    new daytypeRecord({
                                                                                        value : '5',
                                                                                        text : '星期五'
                                                                                    }),
                                                                                    new daytypeRecord({
                                                                                        value : '4',
                                                                                        text : '星期四'
                                                                                    }),
                                                                                    new daytypeRecord({
                                                                                        value : '3',
                                                                                        text : '星期三'
                                                                                    }),
                                                                                    new daytypeRecord({
                                                                                        value : '2',
                                                                                        text : '星期二'
                                                                                    }),
                                                                                    new daytypeRecord({
                                                                                         value : '1',
                                                                                        text : '星期一'
                                                                                    })
                                                                                    ]
                                                                             );
                                                                             judgeDay='1';
                                                                             if(gridday=='星期日'){
                                                                             Ext.getCmp('u_day').setValue('7');
                                                                             }else if(gridday=='星期六'){
                                                                             Ext.getCmp('u_day').setValue('6');
                                                                             }else if(gridday=='星期五'){
                                                                             Ext.getCmp('u_day').setValue('5');
                                                                             }else if(gridday=='星期四'){
                                                                             Ext.getCmp('u_day').setValue('4');
                                                                             }else if(gridday=='星期三'){
                                                                             Ext.getCmp('u_day').setValue('3');
                                                                             }else if(gridday=='星期二'){
                                                                             Ext.getCmp('u_day').setValue('2');
                                                                             }else{
                                                                             Ext.getCmp('u_day').setValue('1');
                                                                             }
                                                                            }
                                                                }
                                                            }
                                            } ]
                                        }, {
                                            colspan : 1,
                                            layout : 'form',
                                            frame : true,
                                            defaultType : 'textfield',
                                            border : false,
                                            baseCls : 'x-plain',
                                            items : [ {
                                                id : 'u_removebettimebutton',
                                                xtype : 'button',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 100,
                                                text : '删除投注时间段',
                                                name : 'u_removebettimebutton',
                                                handler : function () {
                                                    var betrecords=Ext.getCmp('u_bettimestrtext').getSelectionModel().getSelections();
                                                    u_bettimestrStore.remove(betrecords);
                                                    var bo=true;// 判断bettimestrStore是否已经被删除完
                                                    u_bettimestrStore.each(function(record){
                                                        bo=false;
                                                    });
                                                    if(bo){
                                                        judgeDay='3';
                                                    }
                                                }
                                            },{
                                                id : 'u_clearbettimebutton',
                                                xtype : 'button',
                                                allowBlank : false,
                                                validateOnBlur : false,
                                                width: 100,
                                                text : '清空投注时间段',
                                                name : 'u_clearbettimebutton',
                                                handler : function () {
                                                    judgeDay='3';
                                                    u_bettimestrStore.removeAll();
                                                }
                                               
                                            } ]
                                       
                                        } ]
                            }

                            ],
                            buttonAlign : 'center',
                            minButtonWidth : 60,
                            buttons : [
                                    {
                                        text : '修改',
                                        handler : function() {
                                           
                                            if (updateFrom.getForm().findField('u_dayamount').isValid()==false) {
                                               
                                                Ext.Msg.show({
                                                        title : '提示',
                                                        msg : '无法修改,请检查输入项!',
                                                        buttons : Ext.MessageBox.OK,
                                                        icon : Ext.Msg.INFO
                                                });
                                                return;   
                                            }
                                           
                                           
                                            var timestrs='';
                                            u_bettimestrStore.each(function(record){
                                                timestrs+=record.data.betday+'@'+record.data.bettimestrtext+';';
                                            });
                                            Ext.Ajax.request({
                                                        url : 'wagerControl__updateTjWagerControl.action',
                                                        params : {
                                                            'u_merchantid' : u_merchantid,
                                                            'u_ltype' : u_ltype,
                                                            'u_proportion' : Ext.getCmp('u_proportion').value,
                                                            'u_dayamount' : updateFrom.getForm().findField('u_dayamount').getValue(),
                                                            'u_timestr' : timestrs==''?null:timestrs
                                                        },
                                                        success : function(response) {
                                                            if (response.responseText == 'success') {
                                                                judgeDay='3';
                                                                u_timestrStore.removeAll();
                                                                u_bettimestrStore.removeAll();
                                                                Ext.Msg.alert('成功','修改信息成功!');
                                                                search();
                                                                updateWindow.close();
                                                            } else {
                                                                Ext.Msg.alert('失败',response.responseText);
                                                            }
                                                        },
                                                        failure : function() {
                                                            Ext.Msg.alert('失败','修改信息失败');
                                                        }
                                                    });
                                        }
                                    }, {
                                        text : '取消',
                                        handler : function() {
                                            judgeDay='3';
                                            u_timestrStore.removeAll();
                                            u_bettimestrStore.removeAll();
//                                            updateFrom.form.reset();
                                            updateWindow.close();
                                        }
                                    } ]
                        });   
               
                var updateWindow = new Ext.Window({
                    title : '修改',
                    width : 450,
                    resizable : false,
                    autoHeight : true,
                    modal : true,
                    closeAction : 'close',
                    items : [ updateFrom ]
                });
                updateWindow.show();

            }
        } else {
            Ext.Msg.alert('信息', '请选择需要修改的选项!');
        }

    }
    /* ----------------------- public方法 ----------------------- */
    return {
        show : function() {

            // 创建工具栏和搜索栏
            createToolbar();

            // 创建Grid
            createGrid();

            return grid;

        }
    };

}();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值