ComponentGrid.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /**
  2. *
  3. */
  4. Ext.define('erp.view.scm.product.GetUUid.ComponentGrid',{
  5. extend: 'Ext.grid.Panel',
  6. alias: 'widget.erpComponentGrid',
  7. layout : 'fit',
  8. id: 'uuIdGrid',
  9. emptyText : $I18N.common.grid.emptyText,
  10. columnLines : true,
  11. width: 600,
  12. id:'uuIdGrid',
  13. dockedItems: [{
  14. id : 'pagingtoolbar',
  15. xtype: 'erpComponentGridToolbar',
  16. dock: 'bottom',
  17. displayInfo: true
  18. }],
  19. plugins: [Ext.create('erp.view.core.plugin.CopyPasteMenu')],
  20. columnLines: true,
  21. store: Ext.create('Ext.data.Store',{
  22. fields: ['brand','uuid','code','spec','unit','weight','img','action'],
  23. data: [],
  24. autoLoad:true
  25. }),
  26. columns: [{
  27. text: '品牌',
  28. dataIndex: 'brand',
  29. flex: 1,
  30. titleAlign:'center',
  31. renderer: function(val, meta, record) {
  32. if(val.nameCn != null) {
  33. return val.nameCn;
  34. }else{
  35. return "";
  36. }
  37. }
  38. },{
  39. text: '标准料号',
  40. dataIndex: 'uuid',
  41. flex: 1,
  42. hidden:true
  43. },{
  44. text: '原厂型号',
  45. dataIndex: 'code',
  46. flex: 1.5,
  47. listeners:{
  48. afterrender: function(column) {
  49. column.renderer = function(val, meta, record) {
  50. meta.tdAttr = 'data-qtip="点击查看详情"';
  51. return val ;
  52. }
  53. }
  54. }
  55. },{
  56. text: '规格',
  57. dataIndex: 'spec',
  58. flex: 1
  59. },{
  60. text: '单位',
  61. dataIndex: 'unit',
  62. flex: 0.6
  63. },{
  64. text: '净重',
  65. dataIndex: 'weight',
  66. flex: 0.8
  67. },{
  68. text: '图片',
  69. dataIndex: 'img',
  70. flex: 0.8,
  71. listeners:{
  72. afterrender: function(column) {
  73. column.renderer = function(val, meta, record) {
  74. if(val){
  75. // meta.tdAttr = 'data-qtip="<img src='+val+'>"'; onclick='show();'style="position:absolute;left:0;top:0;"
  76. var qtip = '<img src='+val+' width=300 height=250 />';
  77. var str = "<input type='button' value='查看图片' data-qtip='"+qtip+"'>";
  78. return str;
  79. }else{
  80. meta.tdAttr = '';
  81. return "暂无图片"
  82. }
  83. }
  84. }
  85. }
  86. },{
  87. text: '操作',
  88. dataIndex: 'action',
  89. flex: 1,
  90. listeners:{
  91. afterrender: function(column) {
  92. column.renderer = function(val, meta, record) {
  93. return "<input type='button' value='确认选择'/>";
  94. }
  95. }
  96. }
  97. /*
  98. header: '操作',
  99. xtype:'actioncolumn',
  100. cls: 'x-grid-header-1',
  101. sortable:false,
  102. flex: 1,
  103. align:'center',
  104. icon:basePath+'resource/images/32/select.png',
  105. tooltip: '确认选择',
  106. handler: function(grid, rowIndex, colIndex) {
  107. var record = grid.getStore().getAt(rowIndex).data;
  108. if(Ext.getCmp('wind')){
  109. if(caller == 'ProductBatchUUId'){
  110. var grid = Ext.getCmp('grid');
  111. //最后一次选中的行
  112. var lastRe = grid.getSelectionModel().getLastSelected();
  113. lastRe.set("pub_uuid",record.uuid);
  114. }else if(Ext.getCmp('form')){
  115. if(Ext.getCmp('pre_uuid')){
  116. Ext.getCmp('pre_uuid').setValue(record.uuid);
  117. Ext.getCmp('pre_orispeccode').setValue(record.code);
  118. }else if(Ext.getCmp('pr_uuid')){
  119. Ext.getCmp('pr_uuid').setValue(record.uuid);
  120. Ext.getCmp('pr_orispeccode').setValue(record.code);
  121. }
  122. }
  123. Ext.getCmp('wind').close();
  124. }else {
  125. if(parent.caller == 'ProductBatchUUId'){
  126. var grid = parent.Ext.getCmp('grid');
  127. //最后一次选中的行
  128. var lastRe = grid.getSelectionModel().getLastSelected();
  129. lastRe.set("pub_uuid",record.uuid);
  130. }else if(parent.Ext.getCmp('form')){
  131. if(parent.Ext.getCmp('pre_uuid')){
  132. parent.Ext.getCmp('pre_uuid').setValue(record.uuid);
  133. parent.Ext.getCmp('pre_orispeccode').setValue(record.code);
  134. }else if(parent.Ext.getCmp('pr_uuid')){
  135. parent.Ext.getCmp('pr_uuid').setValue(record.uuid);
  136. parent.Ext.getCmp('pr_orispeccode').setValue(record.code);
  137. }
  138. }
  139. parent.Ext.getCmp('uuWin').close();
  140. }
  141. }
  142. */}],
  143. initComponent : function(){
  144. this.callParent(arguments);
  145. },
  146. listeners: {//滚动条有时候没反应,添加此监听器
  147. scrollershow: function(scroller) {
  148. if (scroller && scroller.scrollEl) {
  149. scroller.clearManagedListeners();
  150. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  151. }
  152. },
  153. cellclick:function(view, td, colIdx, record, tr, rowIdx, e){
  154. var field = view.ownerCt.columns[colIdx].dataIndex;
  155. var da = record.data;
  156. if (field == 'code') {
  157. Ext.Ajax.request({//拿到B2C 地址,通过后台获取是生产还是测试环境
  158. url : basePath + 'common/getB2CUrl.action',
  159. async: false,
  160. callback : function(options,success,response){
  161. var res = new Ext.decode(response.responseText);
  162. if(res.exceptionInfo){
  163. showError(res.exceptionInfo);
  164. }else{
  165. window.open(res.b2curl+'/product#/component/'+da.uuid+'/');
  166. }
  167. }
  168. });
  169. }else if(field == 'action'){
  170. if(Ext.getCmp('wind')){
  171. if(caller == 'ProductBatchUUId'){
  172. var grid = Ext.getCmp('grid');
  173. //最后一次选中的行
  174. var lastRe = grid.getSelectionModel().getLastSelected();
  175. lastRe.set("pub_uuid",da.uuid);
  176. }else if(Ext.getCmp('form')){
  177. if(Ext.getCmp('pre_uuid')){
  178. Ext.getCmp('pre_uuid').setValue(da.uuid);
  179. Ext.getCmp('pre_orispeccode').setValue(da.code);
  180. }else if(Ext.getCmp('pr_uuid')){
  181. Ext.getCmp('pr_uuid').setValue(da.uuid);
  182. Ext.getCmp('pr_orispeccode').setValue(da.code);
  183. }
  184. }
  185. Ext.getCmp('wind').close();
  186. }else {
  187. if(parent.caller == 'ProductBatchUUId'){//需要修改将数据自动写回至后台
  188. var grid = parent.Ext.getCmp('grid');
  189. //最后一次选中的行
  190. var lastRe = grid.getSelectionModel().getLastSelected();
  191. lastRe.set("pub_uuid",da.uuid);
  192. lastRe.set("pub_orispeccode",da.code);
  193. }else if(parent.Ext.getCmp('form')){
  194. if(parent.Ext.getCmp('pre_uuid')){
  195. parent.Ext.getCmp('pre_uuid').setValue(da.uuid);
  196. parent.Ext.getCmp('pre_orispeccode').setValue(da.code);
  197. }else if(parent.Ext.getCmp('pr_uuid')){
  198. parent.Ext.getCmp('pr_uuid').setValue(da.uuid);
  199. parent.Ext.getCmp('pr_orispeccode').setValue(da.code);
  200. }
  201. }
  202. parent.Ext.getCmp('uuWin').close();
  203. }
  204. }
  205. }
  206. },
  207. getGridData:function(kindId,page,pageSize){
  208. var tree = Ext.getCmp('tree-panel');
  209. tree.setLoading(true, tree.body);
  210. Ext.Ajax.request({//拿到tree数据
  211. url : basePath + 'scm/product/getProductComponent.action',
  212. params: {
  213. kindId: kindId,
  214. page:page,
  215. pageSize:pageSize
  216. },
  217. async: false,
  218. callback : function(options,success,response){
  219. tree.setLoading(false);
  220. var res = new Ext.decode(response.responseText);
  221. Ext.getCmp('uuIdGrid').store.loadData(res.gridStore.content);
  222. //获取总条数
  223. dataCount = res.gridStore.totalElements;
  224. //总页数
  225. Ext.getCmp('pagingtoolbar').afterOnLoad();
  226. }
  227. });
  228. }
  229. });