|
|
@@ -0,0 +1,212 @@
|
|
|
+Ext.define('saas.view.sys.finish.DataList', {
|
|
|
+ extend: 'Ext.grid.Panel',
|
|
|
+ xtype: 'sys-finish-datalist',
|
|
|
+ //工具类
|
|
|
+ FormUtil: Ext.create('saas.util.FormUtil'),
|
|
|
+ BaseUtil: Ext.create('saas.util.BaseUtil'),
|
|
|
+ autoScroll: true,
|
|
|
+ frame:true,
|
|
|
+ layout:'fit',
|
|
|
+ dataUrl:'/api/common/finish/list',
|
|
|
+
|
|
|
+ tbar: [{
|
|
|
+ width: 250,
|
|
|
+ name: 'ml_caller',
|
|
|
+ xtype: 'displayfield',
|
|
|
+ fieldLable : '结账日'
|
|
|
+ },{
|
|
|
+ xtype:'button',
|
|
|
+ text:'结账',
|
|
|
+ },{
|
|
|
+ xtype:'button',
|
|
|
+ text:'反结账',
|
|
|
+ },'->',{
|
|
|
+ cls:'x-formpanel-btn-blue',
|
|
|
+ xtype:'button',
|
|
|
+ text:'刷新',
|
|
|
+ listeners: {
|
|
|
+ click:function(b){
|
|
|
+ var grid = b.ownerCt.ownerCt;
|
|
|
+ grid.store.loadPage(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+
|
|
|
+ //字段属性
|
|
|
+ columns : [{
|
|
|
+ text : "id",
|
|
|
+ width : 0,
|
|
|
+ dataIndex : "id",
|
|
|
+ xtype : "numbercolumn",
|
|
|
+ },{
|
|
|
+ text:'结账日',
|
|
|
+ dataIndex : "ml_caller",
|
|
|
+ xtype:'datecolumn',
|
|
|
+ width : 200.0,
|
|
|
+ },{
|
|
|
+ text : "操作日期",
|
|
|
+ width : 200.0,
|
|
|
+ dataIndex : "ml_code",
|
|
|
+ xtype:'datecolumn',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text : "操作员",
|
|
|
+ dataIndex : "ml_content",
|
|
|
+ width : 220.0,
|
|
|
+ }],
|
|
|
+
|
|
|
+ condition:'',
|
|
|
+
|
|
|
+ initComponent: function() {
|
|
|
+ var me = this;
|
|
|
+ if(me.columns){
|
|
|
+ var fields = me.columns.map(column => column.dataIndex);
|
|
|
+ me.store = Ext.create('Ext.data.Store',{
|
|
|
+ fields:fields,
|
|
|
+ autoLoad: true,
|
|
|
+ pageSize: 11,
|
|
|
+ data: [],
|
|
|
+ proxy: {
|
|
|
+ timeout:8000,
|
|
|
+ type: 'ajax',
|
|
|
+ url: me.dataUrl,
|
|
|
+ actionMethods: {
|
|
|
+ read: 'GET'
|
|
|
+ },
|
|
|
+ reader: {
|
|
|
+ type: 'json',
|
|
|
+ rootProperty: 'data.list',
|
|
|
+ totalProperty: 'data.total',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ listeners: {
|
|
|
+ beforeload: function (store, op) {
|
|
|
+ var condition = me.condition;
|
|
|
+ if (Ext.isEmpty(condition)) {
|
|
|
+ condition = "";
|
|
|
+ }
|
|
|
+ Ext.apply(store.proxy.extraParams, {
|
|
|
+ number: op._page,
|
|
|
+ size: store.pageSize,
|
|
|
+ condition: JSON.stringify(condition)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Ext.apply(me, {
|
|
|
+ dockedItems:[{
|
|
|
+ xtype: 'pagingtoolbar',
|
|
|
+ dock: 'bottom',
|
|
|
+ displayInfo: true,
|
|
|
+ store: me.store
|
|
|
+ }]
|
|
|
+ });
|
|
|
+ }
|
|
|
+ me.callParent(arguments);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得过滤条件
|
|
|
+ */
|
|
|
+ getCondition: function(items) {
|
|
|
+ var me = this,
|
|
|
+ conditions = [];
|
|
|
+
|
|
|
+ for(var i = 0; i < items.length; i++) {
|
|
|
+ var item = items[i];
|
|
|
+ var field = item.name,
|
|
|
+ func = item.getCondition,
|
|
|
+ value = item.value,
|
|
|
+ condition;
|
|
|
+
|
|
|
+ if(typeof func == 'function') {
|
|
|
+ condition = {
|
|
|
+ type: 'condition',
|
|
|
+ value: func(value)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ var xtype = item.xtype || 'textfield',
|
|
|
+ type = item.fieldType || me.getDefaultFieldType(xtype),
|
|
|
+ operation = item.operation || me.getDefaultFieldOperation(xtype),
|
|
|
+ conditionValue = me.getConditionValue(xtype, value);
|
|
|
+
|
|
|
+ if(!conditionValue) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ condition = {
|
|
|
+ type: type,
|
|
|
+ field: field,
|
|
|
+ operation: operation,
|
|
|
+ value: conditionValue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditions.push(condition);
|
|
|
+ };
|
|
|
+ return conditions;
|
|
|
+ },
|
|
|
+
|
|
|
+ getDefaultFieldType: function(xtype) {
|
|
|
+ var type;
|
|
|
+
|
|
|
+ if(Ext.Array.contains(['numberfield'], xtype)) {
|
|
|
+ type = 'number';
|
|
|
+ }else if(Ext.Array.contains(['datefield', 'condatefield'], xtype)) {
|
|
|
+ type = 'date';
|
|
|
+ }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
|
|
|
+ type = 'enum';
|
|
|
+ }else {
|
|
|
+ type = 'string';
|
|
|
+ }
|
|
|
+
|
|
|
+ return type;
|
|
|
+ },
|
|
|
+
|
|
|
+ getDefaultFieldOperation: function(xtype) {
|
|
|
+ var operation;
|
|
|
+
|
|
|
+ if(Ext.Array.contains(['numberfield'], xtype)) {
|
|
|
+ operation = '=';
|
|
|
+ }else if(Ext.Array.contains(['datefield'], xtype)) {
|
|
|
+ operation = '=';
|
|
|
+ }else if(Ext.Array.contains(['condatefield'], xtype)) {
|
|
|
+ operation = 'between';
|
|
|
+ }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
|
|
|
+ operation = 'in';
|
|
|
+ }else {
|
|
|
+ operation = 'like';
|
|
|
+ }
|
|
|
+
|
|
|
+ return operation;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理部分字段值
|
|
|
+ */
|
|
|
+ getConditionValue: function(xtype, value) {
|
|
|
+ var conditionValue;
|
|
|
+ if(xtype == 'datefield') {
|
|
|
+ conditionValue = Ext.Date.format(new Date(from), 'Y-m-d h:i:s');
|
|
|
+ }else if(xtype == 'condatefield') {
|
|
|
+ var from = value.from,
|
|
|
+ to = value.to;
|
|
|
+
|
|
|
+ conditionValue = Ext.Date.format(new Date(from), 'Y-m-d h:i:s') + ',' + Ext.Date.format(new Date(to), 'Y-m-d h:i:s');
|
|
|
+ }else if(xtype == 'combobox' || xtype == 'combo') {
|
|
|
+ conditionValue = '\'' + value + '\'';
|
|
|
+ }else if(xtype == 'multicombo') {
|
|
|
+ conditionValue = value.map(function(v) {
|
|
|
+ return '\'' + v.value + '\'';
|
|
|
+ }).join(',');
|
|
|
+ }else {
|
|
|
+ conditionValue = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ return conditionValue;
|
|
|
+ },
|
|
|
+
|
|
|
+ refresh:function(){
|
|
|
+ //debugger
|
|
|
+ }
|
|
|
+
|
|
|
+});
|