/**
*
*/
Ext.define('erp.view.scm.product.GetUUid.ComponentGrid',{
extend: 'Ext.grid.Panel',
alias: 'widget.erpComponentGrid',
layout : 'fit',
id: 'uuIdGrid',
emptyText : $I18N.common.grid.emptyText,
columnLines : true,
width: 600,
id:'uuIdGrid',
dockedItems: [{
id : 'pagingtoolbar',
xtype: 'erpComponentGridToolbar',
dock: 'bottom',
displayInfo: true
}],
plugins: [Ext.create('erp.view.core.plugin.CopyPasteMenu')],
columnLines: true,
store: Ext.create('Ext.data.Store',{
fields: ['brand','uuid','code','spec','unit','weight','img','action'],
data: [],
autoLoad:true
}),
columns: [{
text: '品牌',
dataIndex: 'brand',
flex: 1,
titleAlign:'center',
renderer: function(val, meta, record) {
if(val.nameCn != null) {
return val.nameCn;
}else{
return "";
}
}
},{
text: '标准料号',
dataIndex: 'uuid',
flex: 1,
hidden:true
},{
text: '原厂型号',
dataIndex: 'code',
flex: 1.5,
listeners:{
afterrender: function(column) {
column.renderer = function(val, meta, record) {
meta.tdAttr = 'data-qtip="点击查看详情"';
return val ;
}
}
}
},{
text: '规格',
dataIndex: 'spec',
flex: 1
},{
text: '单位',
dataIndex: 'unit',
flex: 0.6
},{
text: '净重',
dataIndex: 'weight',
flex: 0.8
},{
text: '图片',
dataIndex: 'img',
flex: 0.8,
listeners:{
afterrender: function(column) {
column.renderer = function(val, meta, record) {
if(val){
// meta.tdAttr = 'data-qtip="
"'; onclick='show();'style="position:absolute;left:0;top:0;"
var qtip = '
';
var str = "";
return str;
}else{
meta.tdAttr = '';
return "暂无图片"
}
}
}
}
},{
text: '操作',
dataIndex: 'action',
flex: 1,
listeners:{
afterrender: function(column) {
column.renderer = function(val, meta, record) {
return "";
}
}
}
/*
header: '操作',
xtype:'actioncolumn',
cls: 'x-grid-header-1',
sortable:false,
flex: 1,
align:'center',
icon:basePath+'resource/images/32/select.png',
tooltip: '确认选择',
handler: function(grid, rowIndex, colIndex) {
var record = grid.getStore().getAt(rowIndex).data;
if(Ext.getCmp('wind')){
if(caller == 'ProductBatchUUId'){
var grid = Ext.getCmp('grid');
//最后一次选中的行
var lastRe = grid.getSelectionModel().getLastSelected();
lastRe.set("pub_uuid",record.uuid);
}else if(Ext.getCmp('form')){
if(Ext.getCmp('pre_uuid')){
Ext.getCmp('pre_uuid').setValue(record.uuid);
Ext.getCmp('pre_orispeccode').setValue(record.code);
}else if(Ext.getCmp('pr_uuid')){
Ext.getCmp('pr_uuid').setValue(record.uuid);
Ext.getCmp('pr_orispeccode').setValue(record.code);
}
}
Ext.getCmp('wind').close();
}else {
if(parent.caller == 'ProductBatchUUId'){
var grid = parent.Ext.getCmp('grid');
//最后一次选中的行
var lastRe = grid.getSelectionModel().getLastSelected();
lastRe.set("pub_uuid",record.uuid);
}else if(parent.Ext.getCmp('form')){
if(parent.Ext.getCmp('pre_uuid')){
parent.Ext.getCmp('pre_uuid').setValue(record.uuid);
parent.Ext.getCmp('pre_orispeccode').setValue(record.code);
}else if(parent.Ext.getCmp('pr_uuid')){
parent.Ext.getCmp('pr_uuid').setValue(record.uuid);
parent.Ext.getCmp('pr_orispeccode').setValue(record.code);
}
}
parent.Ext.getCmp('uuWin').close();
}
}
*/}],
initComponent : function(){
this.callParent(arguments);
},
listeners: {//滚动条有时候没反应,添加此监听器
scrollershow: function(scroller) {
if (scroller && scroller.scrollEl) {
scroller.clearManagedListeners();
scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
}
},
cellclick:function(view, td, colIdx, record, tr, rowIdx, e){
var field = view.ownerCt.columns[colIdx].dataIndex;
var da = record.data;
if (field == 'code') {
Ext.Ajax.request({//拿到B2C 地址,通过后台获取是生产还是测试环境
url : basePath + 'common/getB2CUrl.action',
async: false,
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo){
showError(res.exceptionInfo);
}else{
window.open(res.b2curl+'/product#/component/'+da.uuid+'/');
}
}
});
}else if(field == 'action'){
if(Ext.getCmp('wind')){
if(caller == 'ProductBatchUUId'){
var grid = Ext.getCmp('grid');
//最后一次选中的行
var lastRe = grid.getSelectionModel().getLastSelected();
lastRe.set("pub_uuid",da.uuid);
}else if(Ext.getCmp('form')){
if(Ext.getCmp('pre_uuid')){
Ext.getCmp('pre_uuid').setValue(da.uuid);
Ext.getCmp('pre_orispeccode').setValue(da.code);
}else if(Ext.getCmp('pr_uuid')){
Ext.getCmp('pr_uuid').setValue(da.uuid);
Ext.getCmp('pr_orispeccode').setValue(da.code);
}
}
Ext.getCmp('wind').close();
}else {
if(parent.caller == 'ProductBatchUUId'){//需要修改将数据自动写回至后台
var grid = parent.Ext.getCmp('grid');
//最后一次选中的行
var lastRe = grid.getSelectionModel().getLastSelected();
lastRe.set("pub_uuid",da.uuid);
lastRe.set("pub_orispeccode",da.code);
}else if(parent.Ext.getCmp('form')){
if(parent.Ext.getCmp('pre_uuid')){
parent.Ext.getCmp('pre_uuid').setValue(da.uuid);
parent.Ext.getCmp('pre_orispeccode').setValue(da.code);
}else if(parent.Ext.getCmp('pr_uuid')){
parent.Ext.getCmp('pr_uuid').setValue(da.uuid);
parent.Ext.getCmp('pr_orispeccode').setValue(da.code);
}
}
parent.Ext.getCmp('uuWin').close();
}
}
}
},
getGridData:function(kindId,page,pageSize){
var tree = Ext.getCmp('tree-panel');
tree.setLoading(true, tree.body);
Ext.Ajax.request({//拿到tree数据
url : basePath + 'scm/product/getProductComponent.action',
params: {
kindId: kindId,
page:page,
pageSize:pageSize
},
async: false,
callback : function(options,success,response){
tree.setLoading(false);
var res = new Ext.decode(response.responseText);
Ext.getCmp('uuIdGrid').store.loadData(res.gridStore.content);
//获取总条数
dataCount = res.gridStore.totalElements;
//总页数
Ext.getCmp('pagingtoolbar').afterOnLoad();
}
});
}
});