| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- Ext.define('erp.view.fa.arp.payplease.PayPleaseDetailGrid',{
- extend:'Ext.grid.Panel',
- alias:'widget.paypleasedetailGrid',
- requires:['erp.view.fa.arp.payplease.PPDtoolbar'],
- layout:'fit',
- id:'paypleasedetailGrid',
- emptyText : $I18N.common.grid.emptyText,
- columnLines : true,
- autoScroll : true,
- detno:'ppdd_detno',
- keyField:'ppdd_id',
- mainField:'ppdd_ppdid',
- columns:[],
- multiselected: [],
- bodyStyle:'bachgroud-color:#f1f1f1;',
- plugins:Ext.create('Ext.grid.plugin.CellEditing',{
- clicksToEdit:1
- }),
- bbar:{
- xtype: 'erpPPDToolbar'
- },
- GridUtil:Ext.create('erp.util.GridUtil'),
- BaseUtil:Ext.create('erp.util.BaseUtil'),
-
- selModel: Ext.create('Ext.selection.CheckboxModel',{
- // checkOnly:true,
- ignoreRightMouseSelection : false,
- getEditor: function(){
- return null;
- },
- onRowMouseDown: function(view, record, item, index, e) {//改写的onRowMouseDown方法
- var status = Ext.getCmp('pp_statuscode');
- var me = Ext.getCmp('paypleasedetailGrid');
-
-
- if(status&&status.value=='AUDITED'){
-
- var bool = true;
- var items = me.selModel.getSelection();
- Ext.each(items, function(item, index){
- if(this.index == record.index){
- bool = false;
- me.selModel.deselect(record);
- Ext.Array.remove(items, item);
- Ext.Array.remove(me.multiselected, record);
- }
- });
- Ext.each(me.multiselected, function(item, index){
- items.push(item);
- });
- me.selModel.select(items);
- if(bool){
- view.el.focus();
- var checkbox = item.childNodes[0].childNodes[0].childNodes[0];
- if(checkbox.getAttribute && checkbox.getAttribute('class') == 'x-grid-row-checker'){
- me.multiselected.push(record);
- items.push(record);
- me.selModel.select(items);
- } else {
- me.selModel.deselect(record);
- Ext.Array.remove(me.multiselected, record);
- }
- }
- }else{
- me.selModel.select(index);
- }
-
-
- // me.summary();
- },
- onHeaderClick: function(headerCt, header, e) {
- if (header.isCheckerHd) {
- e.stopEvent();
- var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
- if (isChecked) {
- this.deselectAll(true);
- var grid = Ext.getCmp('paypleasedetailGrid');
- this.deselect(grid.multiselected);
- grid.multiselected = new Array();
- var els = Ext.select('div[@class=x-grid-row-checker-checked]').elements;
- Ext.each(els, function(el, index){
- el.setAttribute('class','x-grid-row-checker');
- });
- header.el.removeCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');//添加这个
- } else {
- var grid = Ext.getCmp('batchDealGridPanel');
- this.deselect(grid.multiselected);
- grid.multiselected = new Array();
- var els = Ext.select('div[@class=x-grid-row-checker-checked]').elements;
- Ext.each(els, function(el, index){
- el.setAttribute('class','x-grid-row-checker');
- });
- this.selectAll(true);
- header.el.addCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');//添加这个
- }
- }
- // Ext.getCmp('paypleasedetailGrid').summary();
- }
- }),
- // listeners:{
- // activate:function(){
- // console.log(this);
- // console.log(this.readOnly);
- // }
- // },
- /**
- * 修改为selection改变时,summary也动态改变
- */
- // summary: function(){
- // var me = this,
- // store = this.store,
- // value;
- // Ext.each(me.columns, function(c){
- // if(c.summaryType == 'sum'){
- // value = store.getSum(c.dataIndex);
- // me.down('tbtext[id=' + c.dataIndex + '_sum]').setText(c.header + '(sum):' + value);
- // } else if(c.summaryType == 'count'){
- // value = store.getCount();
- // me.down('tbtext[id=' + c.dataIndex + '_count]').setText(c.header + '(count):' + value);
- // } else if(c.summaryType == 'average'){
- // value = store.getAverage(c.dataIndex);
- // me.down('tbtext[id=' + c.dataIndex + '_average]').setText(c.header + '(average):' + value);
- // }
- // });
- // },
- getMultiSelected: function(){
- var grid = this;
- var items = grid.selModel.getSelection();
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- grid.multiselected.push(item);
- }
- });
- return Ext.Array.unique(grid.multiselected);
- },
- initComponent:function(){
- this.callParent(arguments);
- // console.log(urlCondition);
- //得到页面上显示的formCondition属性
- var gridCondition=this.BaseUtil.getUrlParam('gridCondition');
- var condition="";
- if(gridCondition==null){
- var urlCondition = this.BaseUtil.getUrlParam('formCondition');
- //定义通过IS拆分后的数组
- var cons=null;
- //存在urlCondition的情况下
- if(urlCondition){
- //对urlCondition进行拆分 urlCondition的格式一般为pp_idIS1
- cons = urlCondition.split("IS");
- }
- var pp_id=0;
- if(cons!=null){
- if(cons[0]&&cons[1]){
- if(cons[0]!=null&&cons[0]!=''){
- if(cons[1]>0){
- pp_id=cons[1];
- }else{
- pp_id=0;
- }
- }
-
- }
- }
- condition ="ppd_ppid='"+pp_id+"'";
- }else condition=gridCondition.replace(/IS/g,'=');
- this.getMyData(condition);
- },
- // getMultiSelected: function(){
- // var grid = this;
- // var items = grid.selModel.getSelection();
- // Ext.each(items, function(item, index){
- // if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- // && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- // grid.multiselected.push(item);
- // }
- // });
- // return Ext.Array.unique(grid.multiselected);
- // },
- getMyData:function(condition){
-
- var me = this;
- var params = {
- caller:"PayPlease",
- condition:condition
- };
-
- if(me.columns && me.columns.length > 2){
- me.GridUtil.loadNewStore(me,params);
- } else {
- me.GridUtil.getGridColumnsAndStore(me,'common/singleGridPanel.action',params);
-
- }
- // console.log('444');
- //// console.log(me);
- // if(me){
- // console.log(me.readOnly);
- // if(me.readOnly){
- // console.log('rrrr');
- // }
- // }
-
-
-
- }/*,
- getEffectiveData: function(){
- var me = this;
- var effective = new Array();
- var s = this.store.data.items;
- for(var i=0;i<s.length;i++){
- var data = s[i].data;
- if(data[me.keyField] != null && data[me.keyField] != ""){
- effective.push(data);
- }
- }
- return effective;
- },
- setReadOnly: function(bool){
- this.readOnly = bool;
- },
- reconfigure: function(store, columns){
- var d = this.headerCt;
- if (this.columns.length <= 1 && columns) {
- d.suspendLayout = true;
- d.removeAll();
- d.add(columns);
- }
- if (store) {
- try{
- this.bindStore(store);
- } catch (e){
-
- }
- } else {
- this.getView().refresh();
- }
- if (columns) {
- d.suspendLayout = false;
- this.forceComponentLayout();
- }
- this.fireEvent("reconfigure", this);
- },
- *//**
- * Grid上一条
- *//*
- prev: function(grid, record){
- grid = grid || Ext.getCmp('paypleasedetailGrid');
- record = record || grid.selModel.lastSelected;
- if(record){
- //递归查找上一条,并取到数据
- var d = grid.store.getAt(record.index - 1);
- if(d){
- try {
- grid.selModel.select(d);
- return d;
- } catch (e){
-
- }
- } else {
- if(record.index - 1 > 0){
- return this.prev(grid, d);
- } else {
- return null;
- }
- }
- }
- },
- *//**
- * Grid下一条
- *//*
- next: function(grid, record){
- grid = grid || Ext.getCmp('paypleasedetailGrid');
- record = record || grid.selModel.lastSelected;
- if(record){
- //递归查找下一条,并取到数据
- var d = grid.store.getAt(record.index + 1);
- if(d){
- try {
- grid.selModel.select(d);
- return d;
- } catch (e){
-
- }
- } else {
- if(record.index + 1 < grid.store.data.items.length){
- return this.next(grid, d);
- } else {
- return null;
- }
- }
- }
- }*/
-
- });
|