var ttoolbarItems = [ {
xtype : 'textfield',
id : 'serialNum',
fieldLabel : '序列号',
labelWidth : 60,
width : '20%'
},
{
xtype: 'datefield',
id : 'createTime',
fieldLabel : '入库开始时间',
// labelWidth : 60,
// width : '20%'
},{
xtype: 'datefield',
id : 'releaseTime',
fieldLabel : '入库结束时间',
// lableWidth : 60,
// width : '20%'
},
userSelector,
agentSelector,
productSelector,
{
xtype : 'button',
text : '查询',
iconCls : 'x-fa fa-search',
width : 70,
handler : function(btn, eventObj) {
var searchParams = {
serialNum : Ext.getCmp('serialNum').getValue(),
createTime : Ext.getCmp('createTime').getValue(),
releaseTime : Ext.getCmp('releaseTime').getValue(),
normalUserId: Ext.getCmp('user_id').getValue(),
agentId: Ext.getCmp('agent_id').getValue(),
productId: Ext.getCmp('product_id').getValue(),
};
Ext.apply(store.proxy.extraParams, searchParams);
store.loadPage(1);
}
}, {
xtype : 'button',
text : '重置',
iconCls : 'x-fa fa-undo',
width : 70,
handler : function(btn, eventObj) {
Ext.getCmp('serialNum').setValue(null);
Ext.getCmp('createTime').setValue(null);
Ext.getCmp('releaseTime').setValue(null);
Ext.getCmp('user_id').setValue(null);
Ext.getCmp('agent_id').setValue(null);
Ext.getCmp('product_id').setValue(null);
store.proxy.extraParams = {};
store.reload();
}
}, {
xtype: 'button',
text: '出库撤销',
handler: function(){
var result = getInventorySelection(me);
if(result == null){
Ext.Msg.alert('错误提示', '请选择终端!');
return;
}
var window = Ext.create('Forestry.app.inventory.CancelAssignmentWindow', {
selected_ids: result['selected_ids']
});
var form = window.down('form').getForm();
var params = {
'serialNum': result['serialNumStr']
};
form.setValues(params);
window.show();
}
}, {
xtype : 'button',
text : '删除',
iconCls : 'x-fa fa-remove',
width : 70,
handler : function(btn, eventObj) {
var grid = Ext.getCmp("inventory-grid");
if (grid.getSelectionModel().getSelection().length > 0) {
var id = grid.getSelectionModel().getSelection()[0].get('id');
globalObject.confirmTip('删除的记录不可恢复,继续吗?', function(btn) {
if (btn == 'yes') {
grid.getEl().mask("数据删除中,请稍候...");
Ext.Ajax.request({
url : appBaseUri + '/sys/inventory/deleteInventory',
params : {
id : id
},
method : "POST",
success : function(response) {
if (response.responseText != '') {
var res = Ext.JSON.decode(response.responseText);
if (res.success) {
globalObject.msgTip('操作成功');
grid.getStore().reload();
} else {
Ext.Msg.alert('错误提示', res.message);
}
}
grid.getEl().unmask();
},
failure : function(response) {
grid.getEl().unmask();
Ext.Msg.alert('错误提示', '操作失败!');
}
});
}
});
}else {
Ext.Msg.alert('提示', '请选择一条宝贝记录');
}
}
}];
if(globalObject.haveActionMenu(me.cButtons, 'ReceiveInventory')){
ttoolbarItems.splice(3, 0, receiveInventoryBtn);
}
if(globalObject.haveActionMenu(me.cButtons, 'DistributeInventory')){
ttoolbarItems.splice(3, 0, distributeInventoryBtn);
}
var ttoolbar = Ext.create('Ext.toolbar.Toolbar', {
items : ttoolbarItems
});
Ext.apply(this, {
store : store,
tbar : ttoolbar,
bbar : Ext.create('Ext.PagingToolbar', {
store : store,
displayInfo : true
}),
columns : columns,
selModel: Ext.create('Ext.selection.CheckboxModel')
});
store.loadPage(1);
this.callParent(arguments);
}
});
}else{
Ext.define('Forestry.app.inventory.InventoryList', {
extend: 'Ext.grid.Grid',
height: '100%',
requires: [
'Ext.grid.plugin.Editable',
'Ext.grid.plugin.ViewOptions',
'Ext.grid.plugin.PagingToolbar',
'Ext.grid.plugin.SummaryRow',
'Ext.grid.plugin.ColumnResizing',
'Ext.grid.plugin.MultiSelection',
'Ext.grid.plugin.RowExpander'
],
store: store,
shadow: true,
rowLines: true,
itemConfig:{
body:{
tpl:'<div style="color:#aaa;">代理商:{agentRealName}<br/>用户:{userRealName}<br/>入库时间:{createTime:date("Y-m-d H:i:s")}<br/>出库时间:{releaseTime:date("Y-m-d H:i:s")}</div>'
}
},
columns: [
{
text: '序列号',
dataIndex: 'serialNum',
width: window.innerWidth*0.6
},
{
text: '产品',
dataIndex: 'productTitle',
width: window.innerWidth*0.4
}
],
plugins: [{
type: 'grideditable'
}, {
type: 'gridviewoptions'
}, {
type: 'pagingtoolbar'
}, {
type: 'summaryrow'
}, {
type: 'columnresizing'
}, {
type: 'rowexpander'
}]
});
}
})();