CurrencysMonthGrid.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * ERP项目gridpanel通用样式1
  3. */
  4. Ext.define('erp.view.fa.fix.CurrencysMonthGrid',{
  5. extend: 'Ext.grid.Panel',
  6. alias: 'widget.currencysMonthGrid',
  7. region: 'south',
  8. layout : 'fit',
  9. id: 'grid',
  10. emptyText : $I18N.common.grid.emptyText,
  11. columnLines : true,
  12. autoScroll : true,
  13. store: [],
  14. columns: [],
  15. tbar:[{
  16. xtype:'monthdatefield',
  17. id:'monthfield'
  18. },{
  19. id:'searchCurrency',
  20. cls: 'x-btn-gray',
  21. iconCls: 'x-button-icon-query',
  22. width: 60,
  23. text:'查看'
  24. },{
  25. xtype:'erpSaveButton'
  26. },{
  27. xtype:'erpDeleteButton'
  28. },{
  29. text: '取上期月末汇率',
  30. name: 'getlastend',
  31. cls: 'x-btn-gray',
  32. margin: '0 0 0 5'
  33. },{
  34. text: '取月初汇率',
  35. name: 'getcrrate',
  36. cls: 'x-btn-gray',
  37. margin: '0 0 0 5'
  38. },{
  39. xtype:'erpCloseButton'
  40. },{
  41. xtype:'erpSyncButton'
  42. }],
  43. GridUtil: Ext.create('erp.util.GridUtil'),
  44. BaseUtil: Ext.create('erp.util.BaseUtil'),
  45. plugins: Ext.create('Ext.grid.plugin.CellEditing', {
  46. clicksToEdit: 1
  47. }),
  48. initComponent : function(){
  49. var gridCondition = this.BaseUtil.getUrlParam('gridCondition');
  50. gridCondition = (gridCondition == null || gridCondition == "null") ? "" : gridCondition;
  51. var conf = ' 1=1 ';
  52. if(Ext.String.trim(gridCondition)==''||Ext.String.trim(gridCondition)==null||Ext.String.trim(gridCondition)=='null'){
  53. var searchfield = Number(Ext.Date.format(new Date(), 'Ym'));
  54. conf = conf+' and cm_yearmonth='+searchfield;
  55. }else{
  56. conf = conf+gridCondition;
  57. }
  58. var gridParam = {caller: caller, condition: conf};
  59. this.GridUtil.getGridColumnsAndStore(this, 'common/singleGridPanel.action', gridParam, "");
  60. this.callParent(arguments);
  61. },
  62. getGridStore: function(){
  63. var grid = this;
  64. var jsonGridData = new Array();
  65. var s = grid.getStore().data.items;//获取store里面的数据
  66. for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  67. var data = s[i].data;
  68. if(s[i].dirty){
  69. var bool = true;
  70. Ext.each(grid.necessaryField, function(f){
  71. if(data[f] == null){
  72. bool = false;
  73. showError("有必填项未填写!代号:" + f);return;
  74. }
  75. });
  76. if(bool){
  77. Ext.each(grid.columns, function(c){
  78. if(c.xtype == 'datecolumn'){
  79. if(Ext.isDate(data[c.dataIndex])){
  80. data[c.dataIndex] = Ext.Date.toString(data[c.dataIndex]);//在这里把GMT日期转化成Y-m-d格式日期
  81. } else {
  82. data[c.dataIndex] = Ext.Date.format(new Date(), 'Y-m-d');//如果用户没输入日期,或输入有误,就给个默认日期,
  83. //或干脆return;并且提示一下用户
  84. }
  85. } else if(c.xtype == 'datetimecolumn'){
  86. if(Ext.isDate(data[c.dataIndex])){
  87. data[c.dataIndex] = Ext.Date.format(data[c.dataIndex], 'Y-m-d H:i:s');//在这里把GMT日期转化成Y-m-d H:i:s格式日期
  88. } else {
  89. data[c.dataIndex] = Ext.Date.format(new Date(), 'Y-m-d H:i:s');//默认日期,
  90. }
  91. } else if(c.xtype == 'numbercolumn'){//赋个默认值0吧,不然不好保存
  92. if(data[c.dataIndex] == null || data[c.dataIndex] == ''){
  93. data[c.dataIndex] = '0';//也可以从data里面去掉这些字段
  94. }
  95. }
  96. });
  97. jsonGridData.push(Ext.JSON.encode(data));
  98. }
  99. }
  100. }
  101. return jsonGridData;
  102. }
  103. });