AccountDetails.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. Ext.define('saas.view.money.report.AccountDetails', {
  2. extend: 'Ext.grid.Panel',
  3. xtype: 'monry-report-accountdetails',
  4. controller: 'money-report-accountdetails',
  5. viewModel: 'money-report-accountdetails',
  6. viewName: 'money-report-accountdetails',
  7. autoScroll: true,
  8. frame:true,
  9. layout:'fit',
  10. //工具类
  11. FormUtil: Ext.create('saas.util.FormUtil'),
  12. BaseUtil: Ext.create('saas.util.BaseUtil'),
  13. // groupField: null,
  14. dataUrl: '/api/money/report/accountdetails',
  15. defaultCondition: null,
  16. reportTitle: '核销对账表',
  17. QueryWidth:0.25,
  18. //筛选:客户/供应商、日期、单据类型(必填)
  19. tbar: [{
  20. width: 150,
  21. name: 'sl_kind',
  22. xtype: 'textfield',
  23. emptyText : '单据类型'
  24. },{
  25. width: 400,
  26. name: 'date',
  27. xtype: 'condatefield',
  28. emptyText : '单据日期'
  29. },{
  30. width: 200,
  31. name: 've_name',
  32. xtype: 'textfield',
  33. emptyText : '供应商名称'
  34. },{
  35. width: 200,
  36. name: 'cu_name',
  37. xtype: 'textfield',
  38. emptyText : '客户名称'
  39. },{
  40. cls:'x-formpanel-btn-orange',
  41. xtype:'button',
  42. text:'查询',
  43. listeners: {
  44. click:function(b){
  45. var grid = b.ownerCt.ownerCt;
  46. var tbar = b.ownerCt;
  47. grid.condition = '';
  48. var items = [];
  49. var fields = tbar.items.items.map(f => f.name);
  50. Ext.each(fields, function(f, index){
  51. var field = tbar.down('[name='+f+']');
  52. if(field){
  53. items.push(field);
  54. }
  55. });
  56. grid.condition = grid.getCondition(items);
  57. grid.store.loadPage(1);
  58. }
  59. }
  60. },'->'],
  61. columns: [
  62. {
  63. text: 'id',
  64. dataIndex: 'pi_id',
  65. hidden: true
  66. }, {
  67. text: '单据编号',
  68. dataIndex: 'sl_code',
  69. width: 150
  70. }, {
  71. text: '单据类型',
  72. dataIndex: 'sl_kind',
  73. width: 110
  74. }, {
  75. text: '单据日期',
  76. dataIndex: 'date',
  77. xtype:'datecolumn',
  78. width: 110
  79. },{
  80. text:'供应商名称',
  81. dataIndex:'ve_name',
  82. width: 200
  83. },{
  84. text:'客户名称',
  85. dataIndex:'cu_name',
  86. width: 200
  87. },{
  88. text:'核销单号',
  89. dataIndex:'pb_code',
  90. width: 200
  91. },{
  92. text: '本期核销金额',
  93. dataIndex: 'sl_amount',
  94. xtype: 'numbercolumn',
  95. width: 130,
  96. // renderer : function(v) {
  97. // var arr = (v + '.').split('.');
  98. // var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  99. // var format = '0.' + xr.join();
  100. // return Ext.util.Format.number(v, format);
  101. // },
  102. // summaryType: 'sum',
  103. // summaryRenderer: function(v) {
  104. // var arr = (v + '.').split('.');
  105. // var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  106. // var format = '0.' + xr.join();
  107. // return Ext.util.Format.number(v, format);
  108. // }
  109. },{
  110. text: '总金额',
  111. dataIndex: 'total',
  112. xtype: 'numbercolumn',
  113. width: 110,
  114. // renderer : function(v) {
  115. // var arr = (v + '.').split('.');
  116. // var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  117. // var format = '0,000.' + xr.join();
  118. // return Ext.util.Format.number(v, format);
  119. // },
  120. // summaryType: 'sum',
  121. // summaryRenderer: function(v) {
  122. // var arr = (v + '.').split('.');
  123. // var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  124. // var format = '0,000.' + xr.join();
  125. // return Ext.util.Format.number(v, format);
  126. // }
  127. }],
  128. dbSearchFields: [],
  129. condition:'',
  130. initComponent: function() {
  131. var me = this;
  132. if(me.columns){
  133. var fields = me.columns.map(column => column.dataIndex);
  134. me.store = Ext.create('Ext.data.Store',{
  135. fields:fields,
  136. autoLoad: true,
  137. pageSize: 11,
  138. data: [],
  139. proxy: {
  140. timeout:8000,
  141. type: 'ajax',
  142. url: me.dataUrl,
  143. actionMethods: {
  144. read: 'GET'
  145. },
  146. reader: {
  147. type: 'json',
  148. rootProperty: 'data.list.list',
  149. totalProperty: 'data.list.total',
  150. }
  151. },
  152. listeners: {
  153. beforeload: function (store, op) {
  154. var condition = me.condition;
  155. if (Ext.isEmpty(condition)) {
  156. condition = "";
  157. }
  158. Ext.apply(store.proxy.extraParams, {
  159. number: op._page,
  160. size: store.pageSize,
  161. condition: JSON.stringify(condition)
  162. });
  163. }
  164. }
  165. });
  166. Ext.apply(me, {
  167. dockedItems:[{
  168. xtype: 'pagingtoolbar',
  169. dock: 'bottom',
  170. displayInfo: true,
  171. store: me.store
  172. }]
  173. });
  174. }
  175. me.callParent(arguments);
  176. },
  177. getGridSelected:function(type){
  178. var isErrorSelect = false;
  179. var checkField = this.statusCodeField;
  180. var me = this,
  181. items = me.selModel.getSelection(),
  182. data = new Array() ;
  183. Ext.each(items, function(item, index){
  184. if(!Ext.isEmpty(item.data[me.idField])){
  185. var o = new Object();
  186. if(me.idField){
  187. o['id'] = item.data[me.idField];
  188. }
  189. if(me.codeField){
  190. o['code'] = item.data[me.codeField];
  191. }
  192. if(type&&type==item.data[checkField]){
  193. isErrorSelect = true
  194. }
  195. data.push(o);
  196. }
  197. });
  198. if(isErrorSelect){
  199. return false;
  200. }
  201. return data;
  202. },
  203. /**
  204. * 获得过滤条件
  205. */
  206. getCondition: function(items) {
  207. var me = this,
  208. conditions = [];
  209. for(var i = 0; i < items.length; i++) {
  210. var item = items[i];
  211. var field = item.name,
  212. func = item.getCondition,
  213. value = item.value,
  214. condition;
  215. if(typeof func == 'function') {
  216. condition = {
  217. type: 'condition',
  218. value: func(value)
  219. }
  220. }else {
  221. var xtype = item.xtype || 'textfield',
  222. type = item.fieldType || me.getDefaultFieldType(xtype),
  223. operation = item.operation || me.getDefaultFieldOperation(xtype),
  224. conditionValue = me.getConditionValue(xtype, value);
  225. if(!conditionValue) {
  226. continue;
  227. }
  228. condition = {
  229. type: type,
  230. field: field,
  231. operation: operation,
  232. value: conditionValue
  233. }
  234. }
  235. conditions.push(condition);
  236. };
  237. return conditions;
  238. },
  239. getDefaultFieldType: function(xtype) {
  240. var type;
  241. if(Ext.Array.contains(['numberfield'], xtype)) {
  242. type = 'number';
  243. }else if(Ext.Array.contains(['datefield', 'condatefield'], xtype)) {
  244. type = 'date';
  245. }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
  246. type = 'enum';
  247. }else {
  248. type = 'string';
  249. }
  250. return type;
  251. },
  252. getDefaultFieldOperation: function(xtype) {
  253. var operation;
  254. if(Ext.Array.contains(['numberfield'], xtype)) {
  255. operation = '=';
  256. }else if(Ext.Array.contains(['datefield'], xtype)) {
  257. operation = '=';
  258. }else if(Ext.Array.contains(['condatefield'], xtype)) {
  259. operation = 'between';
  260. }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
  261. operation = 'in';
  262. }else {
  263. operation = 'like';
  264. }
  265. return operation;
  266. },
  267. /**
  268. * 处理部分字段值
  269. */
  270. getConditionValue: function(xtype, value) {
  271. var conditionValue;
  272. if(xtype == 'datefield') {
  273. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
  274. }else if(xtype == 'condatefield') {
  275. var from = value.from,
  276. to = value.to;
  277. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
  278. }else if(xtype == 'combobox' || xtype == 'combo') {
  279. conditionValue = '\'' + value + '\'';
  280. }else if(xtype == 'multicombo') {
  281. conditionValue = value.map(function(v) {
  282. return '\'' + v.value + '\'';
  283. }).join(',');
  284. }else {
  285. conditionValue = value;
  286. }
  287. return conditionValue;
  288. },
  289. refresh:function(){
  290. //debugger
  291. }
  292. });