| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- 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/commons/endProduct/list',
- endAccount:'/api/commons/endProduct/endAccount',
- unEndAccount:'/api/commons/endProduct/unEndAccount',
- tbar: [{
- cls:'x-tbar-display',
- width: 180,
- name: 'day',
- xtype: 'displayfield'
- },{
- xtype:'button',
- text:'结账',
- listeners: {
- click:function(b){
- var grid = b.ownerCt.ownerCt;
- grid.BaseUtil.request({
- url: grid.endAccount,
- params: '',
- method: 'POST',
- })
- .then(function(localJson) {
- if(localJson.success){
- showToast('结账成功');
- grid.store.loadPage(1);
- }
- })
- .catch(function(res) {
- console.error(res);
- showToast('结账失败: ' + res.message);
- });
- }
- }
- },{
- xtype:'button',
- text:'反结账',
- listeners: {
- click:function(b){
- var grid = b.ownerCt.ownerCt;
- grid.BaseUtil.request({
- url: grid.unEndAccount,
- params: '',
- method: 'POST',
- })
- .then(function(localJson) {
- if(localJson.success){
- showToast('反结账成功');
- grid.store.loadPage(1);
- }
- })
- .catch(function(res) {
- console.error(res);
- showToast('反结账失败: ' + res.message);
- });
- }
- }
- },'->',{
- 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_keyvalue",
- xtype:'',
- width : 160.0,
- },{
- text : "操作日期",
- width : 200.0,
- format:'Y-m-d H:i:s',
- dataIndex : "createTime",
- xtype:'datecolumn',
- },
- {
- text : "操作类型",
- dataIndex : "ml_content",
- width : 220.0,
- },
- {
- text : "操作员",
- dataIndex : "ml_man",
- width : 170.0,
- },
- {
- text : "结果",
- dataIndex : "ml_result",
- 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: {
- parent:this,
- async:false,
- timeout:8000,
- type: 'ajax',
- url: me.dataUrl,
- actionMethods: {
- read: 'GET'
- },
- reader: {
- type: 'json',
- rootProperty: 'data.item.list',
- totalProperty: 'data.total',
- },
- listeners:{
- endprocessresponse:function(proxy,res){
- if(res.status=='200'){
- var nowTime = res.responseJson.data.main;
- var day = proxy.parent.dockedItems.items[2].down('[name=day]');
- day.setValue('当前结算年月:' + nowTime);
- }
- }
- }
- },
- 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)
- });
- },
- datachanged:function(){
-
- }
- }
- });
- 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 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
- }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(){
- this.ownerCt.setTitle('结账/反结账')
- }
- });
|