123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- /**
- *
- */
- 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="<img src='+val+'>"'; onclick='show();'style="position:absolute;left:0;top:0;"
- var qtip = '<img src='+val+' width=300 height=250 />';
- var str = "<input type='button' value='查看图片' data-qtip='"+qtip+"'>";
- return str;
- }else{
- meta.tdAttr = '';
- return "暂无图片"
- }
- }
- }
- }
- },{
- text: '操作',
- dataIndex: 'action',
- flex: 1,
- listeners:{
- afterrender: function(column) {
- column.renderer = function(val, meta, record) {
- return "<input type='button' value='确认选择'/>";
- }
- }
- }
- /*
- 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();
- }
- });
- }
- });
|