HomeController.js 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. Ext.define('saas.view.home.HomeController', {
  2. extend: 'Ext.app.ViewController',
  3. alias: 'controller.home',
  4. onDataRender: function (v) {
  5. return v + '%';
  6. },
  7. setDefaultCurrency:function(){
  8. var win = Ext.create('Ext.window.Window', {
  9. id:'x-defaultcurrency',
  10. cls:'x-window-dbfind',
  11. height: 100,
  12. width: 450,
  13. modal:true,
  14. title: '本位币设置',
  15. bodyPadding: 10,
  16. constrain: true,
  17. closable: false,
  18. layout: {
  19. type: 'vbox',
  20. align: 'center'
  21. },
  22. items:[{
  23. xtype:'panel',
  24. layout:'hbox',
  25. items:[{
  26. belong:'form',
  27. dbfinds:[{
  28. from:'cr_name',to:'defaultCurrency'
  29. }],
  30. margin:'0 10 0 0',
  31. labelWidth:60,
  32. allowBlank:false,
  33. xtype : "currencyDbfindTrigger",
  34. name : "defaultCurrency",
  35. fieldLabel : "本位币",
  36. beforeLabelTextTpl : "<font color=\"red\" style=\"position:relative; top:2px;right:2px; font-weight: bolder;\">*</font>",
  37. onAddClick: function() {
  38. var me=this;
  39. var tab = me.ownerCt;
  40. // this.isEdit = !!record;
  41. this.dialog = tab.add({
  42. xtype: 'document-currencys-addwindow',
  43. _parent:this,
  44. session: true
  45. });
  46. this.dialog.show();
  47. }
  48. },{
  49. margin:'0 0 0 5',
  50. xtype:'button',
  51. text:'确认',
  52. handler:function(b){
  53. var v = b.ownerCt.down('[name=defaultCurrency]').value;
  54. if(!v||v==''||v==null){
  55. saas.util.BaseUtil.showErrorToast('请选择币别');
  56. return;
  57. }
  58. saas.util.BaseUtil.showConfirm('提示', '确定使用选择的币别: '+v+' 作为本位币吗(无法修改)?')
  59. .then(function(yes) {
  60. if(yes == 'yes') {
  61. var formData = [];
  62. formData.push({
  63. code:'defaultCurrency',
  64. data:v
  65. })
  66. saas.util.BaseUtil.request({
  67. url: '/api/commons/configs/update',
  68. params: JSON.stringify(formData),
  69. method: 'POST',
  70. })
  71. .then(function(localJson) {
  72. if(localJson.success){
  73. saas.util.BaseUtil.showSuccessToast('本位币设置成功');
  74. Ext.getCmp('mainView').getViewModel().set('defaultCurrency', v);
  75. Ext.getCmp('x-defaultcurrency').close();
  76. }
  77. })
  78. .catch(function(res) {
  79. console.error(res);
  80. saas.util.BaseUtil.showErrorToast('本位币设置失败: ' + res.message);
  81. });
  82. }else {
  83. throw new Error();
  84. }
  85. })
  86. }
  87. }]
  88. }]
  89. });
  90. win.show();
  91. }
  92. });