EXT6.js创建页面4

21 篇文章 0 订阅
6 篇文章 0 订阅
/**
 * Created by Cy on 2016/10/17.
 */
Ext.define('BSWeb.view.business.community.CommunityController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.CommunityInfo',
    control: {
        '#CommunityItemId': {
            show: 'CommunityInfo',
            activate: 'CommunityInfoActivate',
            itemmousedown: 'CommunityInfoMousedown'
        },
        '#CommunityPageItemId': {
            change: 'CommunityPageChange'
        },
        '#add': {
            click: 'addFn'
        },
        '#saveAdd': {
            click: 'saveAddFn'
        },
        '#cancelAdd': {
            click: 'canceAddlFn'
        },
        '#update': {
            click: 'updateFn'
        },
        '#saveUpdate': {
            click: 'saveUpdateFn'
        },
        '#cancelUpdate': {
            click: 'cancelUpdateFn'
        },
        '#delete': {
            click: 'deleteFn'
        },
        '#search': {
            click: 'searchFn'
        },
        '#searchText': {
            keyup: 'searchKeypressFn'
        }
    },
    CommunityInfo: function (_this, _eOpts) {
        var pagecom = Ext.ComponentQuery.query('pagingtoolbar#CommunityPageItemId')[0];
        console.log(pagecom);
        pagecom.getStore().load({
            params: {
                strName: ''
            }
        });

    },
    CommunityInfoActivate: function (_this) {

        //console.log('1')
    },

    CommunityInfoMousedown: function (_this, record, item, index, e, eOpts) {
        //BSWeb.Re=record;
        //console.log(record);
        //console.log(e);
        //console.log(e.browserEvent.which);
        if (e.browserEvent.which === 3) {
            document.oncontextmenu = function (e) {
                return false;
            };
            //console.log(Ext.getBody());
        }
    },

    CommunityPageChange: function (_this, _pageData, _eOpts) {
        var  refreshData = Ext.ComponentQuery.query('gridpanel#CommunityItemId')[0];
      refreshData.getStore().load({
            params: {
                page: _pageData.currentPage,
                limit: 10,
                strName: ''
            }
        })

        //console.log();
        //_this.getStore().load();
    },
    addFn: function (_this, e, eOpts) {
        //alert('info');
        Ext.create('BSWeb.view.business.communityinfo.AddCommunity').show();
    },
    saveAddFn: function (_this, e, eOpts) {
        //alert('info');
        //console.log('info');
        //_this.up('#UserMaintainaAddFrom').loadRecord(BSWeb.Re);
        //console.log(_this.up('#UserMaintainaFrom').getValues());

        var params, myform, mywindows, results, refreshData;
        mywindows = _this.up('#Com');
        myform = _this.up('#ComFrom');
        params = myform.getValues();
        refreshData = Ext.ComponentQuery.query('pagingtoolbar#CommunityPageItemId')[0];
        BSWeb.AjaxUtil.getResponseApi(mywindows, 'api/BusCommunityInfo/AddCom', 'POST', params, true).then(function (context) {
            //console.log(context);
            if (context.status === 200) {
                results = Ext.JSON.decode(context.responseText, true);
                if (results.identifying === 2) {
                    refreshData.getStore().load({
                        params: {

                            strName: Ext.ComponentQuery.query('textfield#searchText')[0].getValue()
                        }
                    });
                    Ext.toast(results.message);
                    _this.up('#Com').close();

                } else {
                    Ext.Msg.alert('失败提示', results.message);
                }
            }

        })
    },
    canceAddlFn: function (_this, e, eOpts) {
        _this.up('#Com').close();
    },
    updateFn: function (_this, e, eOpts) {
        //alert('info!');
        var grid, selectarray, updatewindows;
        grid = _this.up('#CommunityItemId');
        selectarray = grid.getSelection();
        updatewindows = Ext.create('BSWeb.view.business.communityinfo.Updacommunity');

        //console.log(grid.getSelection());
        if (selectarray.length > 0 && selectarray.length < 2) {
            //console.log(selectarray[0].data);
            updatewindows.down('#UpComFrom').loadRecord(selectarray[0]);
            updatewindows.show();
        } else {
            Ext.toast('请选择要修改的行!');
        }
    },
    saveUpdateFn: function (_this, e, eOpts) {
        var params, myfrom, mywindows, results, refreshData;
        mywindows = _this.up('#UpCom');
        myfrom = mywindows.down('#UpComFrom');
        params = myfrom.getValues();
        params.Uni_CommGuid = myfrom.getRecord().data.Uni_CommGuid;
        refreshData = Ext.ComponentQuery.query('pagingtoolbar#CommunityPageItemId')[0];
        BSWeb.AjaxUtil.getResponseApi(mywindows, 'api/BusCommunityInfo/UpdateCom', 'POST', params, true).then(function (context) {
            if (context.status === 200) {
                results = Ext.JSON.decode(context.responseText, true);
                if (results.identifying === 2) {
                    refreshData.getStore().load({
                        params: {

                            strName: Ext.ComponentQuery.query('textfield#searchText')[0].getValue()
                        }
                    });
                    Ext.toast(results.message);
                    mywindows.close();
                } else {
                    Ext.Msg.alert('失败提示', results.message);
                }
            }

        })

    },
    cancelUpdateFn: function (_this, e, eOpts) {
        _this.up('#UpCom').close();
    },
    deleteFn: function (_this, e, eOpts) {
        // alert('info!');
        //console.log('delete');
        var grid, selectarray, params, results, refreshData;
        grid = _this.up('#CommunityItemId');
        selectarray = grid.getSelection();
        refreshData = Ext.ComponentQuery.query('pagingtoolbar#CommunityPageItemId')[0];
        if (selectarray.length > 0 && selectarray.length < 2) {
            //console.log(selectarray[0].data);
            //alert('info:我要删除当前的行。')
            params = grid.getSelection()[0].data;
            Ext.Msg.show({
                title: '删除提示?',
                message: '确定删除当前(' + selectarray[0].data.V_ProperName + '楼盘' + selectarray[0].data.V_CommName + ')的信息?',
                buttons: Ext.Msg.YESNO,
                icon: Ext.Msg.QUESTION,
                fn: function (btn) {
                    //console.log(btn);
                    if (btn === 'yes') {
                        //console.log(1);
                        BSWeb.AjaxUtil.getResponseApi(grid, 'api/BusCommunityInfo/DeleteCom', 'POST', params, true).then(function (context) {
                            if (context.status === 200) {
                                results = Ext.JSON.decode(context.responseText, true);
                                if (results.identifying === 2) {
                                    refreshData.getStore().load({
                                        params: {

                                            strName: Ext.ComponentQuery.query('textfield#searchText')[0].getValue()
                                        }
                                    });
                                    Ext.toast(results.message);

                                } else {
                                    Ext.toast(results.message);
                                }
                            }
                        })
                    }
                    if (btn === 'no') {
                        //console.log(2);
                    }
                }

            })
        } else {
            //alert('info!');
            Ext.toast('请选择要删除当前行!');
        }
    },
    searchFn: function (_this, e, eOpts) {
        //alert('info:1')
        var refreshData;
        refreshData = Ext.ComponentQuery.query('pagingtoolbar#CommunityPageItemId')[0];
        refreshData.getStore().load({
            params: {
                strName: Ext.ComponentQuery.query('textfield#searchText')[0].getValue()
            }
        })
    },
    searchKeypressFn: function (_this, e, eOpts) {
        //console.log(_this.getValue());
    }
})

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值