/**
* 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());
}
})
EXT6.js创建页面4
最新推荐文章于 2019-06-21 14:06:45 发布