Ext.define('saas.view.home.HomeController', { extend: 'Ext.app.ViewController', alias: 'controller.home', onDataRender: function (v) { return v + '%'; }, setDefaultCurrency:function(){ var win = Ext.create('Ext.window.Window', { id:'x-defaultcurrency', cls:'x-window-dbfind', height: 100, width: 450, modal:true, title: '本位币设置', bodyPadding: 10, constrain: true, closable: false, layout: { type: 'vbox', align: 'center' }, items:[{ xtype:'panel', layout:'hbox', items:[{ belong:'form', dbfinds:[{ from:'cr_name',to:'defaultCurrency' }], margin:'0 10 0 0', labelWidth:60, allowBlank:false, xtype : "currencyDbfindTrigger", name : "defaultCurrency", fieldLabel : "本位币", beforeLabelTextTpl : "*", onAddClick: function() { var me=this; var tab = me.ownerCt; // this.isEdit = !!record; this.dialog = tab.add({ xtype: 'document-currencys-addwindow', _parent:this, session: true }); this.dialog.show(); } },{ margin:'0 0 0 5', xtype:'button', text:'确认', handler:function(b){ var v = b.ownerCt.down('[name=defaultCurrency]').value; if(!v||v==''||v==null){ saas.util.BaseUtil.showErrorToast('请选择币别'); return; } saas.util.BaseUtil.showConfirm('提示', '确定使用选择的币别: '+v+' 作为本位币吗(无法修改)?') .then(function(yes) { if(yes == 'yes') { var formData = []; formData.push({ code:'defaultCurrency', data:v }) saas.util.BaseUtil.request({ url: '/api/commons/configs/update', params: JSON.stringify(formData), method: 'POST', }) .then(function(localJson) { if(localJson.success){ saas.util.BaseUtil.showSuccessToast('本位币设置成功'); Ext.getCmp('mainView').getViewModel().set('defaultCurrency', v); Ext.getCmp('x-defaultcurrency').close(); } }) .catch(function(res) { console.error(res); saas.util.BaseUtil.showErrorToast('本位币设置失败: ' + res.message); }); }else { throw new Error(); } }) } }] }] }); win.show(); } });