| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.ma.SysUpdate', {
- extend : 'Ext.app.Controller',
- requires : [ 'erp.util.BaseUtil' ],
- views : [ 'ma.SysUpdate' ],
- init : function() {
- var me = this;
- this.BaseUtil = Ext.create('erp.util.BaseUtil');
- this.control({
- 'button[id=check]' : {//一键升级
- click : function(btn) {
- var grid = Ext.getCmp('update-grid');
- grid.store.each(function(item){
- if(!item.get('installed')) {
- me.install(item, grid.store.indexOf(item));
- }
- });
- }
- },
- 'button[id=close]' : {
- click : function() {
- me.BaseUtil.getActiveTab().close();
- }
- },
- 'gridpanel[id=update-grid]' : {
- afterrender : function(grid) {
- me.getPatchInfo(grid);
- grid.install = function(idx) {
- me.install(grid.store.getAt(idx));
- };
- grid.uninstall = function(idx) {
- me.uninstall(grid.store.getAt(idx));
- };
- }
- }
- });
- },
- getPatchInfo: function(grid, idx) {
- Ext.Ajax.request({
- url: basePath + 'ma/patch/getInfo.action',
- method: 'GET',
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.success) {
- var u = rs.usoft, p = Ext.Array.pluck(rs.local, 'name');
- if(u != null && u.length > 0) {
- Ext.each(u, function(){
- if(Ext.Array.contains(p, this.name)) {
- this.installed = true;
- } else {
- this.installed = false;
- }
- });
- grid.store.loadData(u);
- } else {
- grid.store.loadData(rs.local);
- }
- } else {
- if(rs.exceptionInfo) {
- showError(rs.exceptionInfo);
- }
- }
- }
- });
- },
- install: function(record) {
- Ext.Ajax.request({
- url: basePath + 'ma/patch/install.action',
- params: {
- pname: record.get('name'),
- files: record.get('files')
- },
- timeout: 50000,
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.success) {
- record.set('installed', true);
- showMessage('提示', '补丁包' + record.get('name') + '已成功安装,请立即重启服务器生效!');
- }
- }
- });
- },
- uninstall: function(record) {
- Ext.Ajax.request({
- url: basePath + 'ma/patch/uninstall.action',
- params: {
- pname: record.get('name')
- },
- timeout: 50000,
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.success) {
- record.set('installed', false);
- showMessage('提示', '补丁包' + record.get('name') + '已成功卸载,服务器现在重启,请勿执行任何操作!');
- }
- }
- });
- }
- });
|