Product.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**
  2. * 产品库
  3. */
  4. Ext.define('saas.view.sale.b2b.Product', {
  5. extend: 'saas.view.core.base.BasePanel',
  6. xtype: 'sale-b2b-product',
  7. viewName: 'sale-b2b-Product',
  8. // dataUrl: 'http://10.1.80.23:8560/api/document/product/prodStorage/list',
  9. dataUrl: '/api/document/product/prodStorage/list',
  10. initComponent: function() {
  11. var me = this;
  12. Ext.apply(this, {
  13. searchField: [{
  14. xtype: 'textfield',
  15. name: 'keyword',
  16. columnWidth: 0.2,
  17. emptyText:'物料编号/名称/型号/品牌',
  18. getCondition: function(value) {
  19. return ' (prodCode like\'%' + value + '%\' or prodBrand like \'%'+value+'%\' or prodName like \'%'+value+'%\' or prodOriSpeccode like \'%'+value+'%\') ';
  20. }
  21. }, {
  22. xtype: 'combobox',
  23. name: 'b2bStatus',
  24. fieldLabel: '上传状态',
  25. queryMode: 'local',
  26. displayField: 'name',
  27. valueField: 'value',
  28. emptyText :'全部',
  29. value: 0,
  30. editable:true,
  31. labelWidth: 80,
  32. columnWidth: 0.2,
  33. store: Ext.create('Ext.data.ArrayStore', {
  34. fields: ['name', 'value'],
  35. data: [
  36. ["全部", "all"],
  37. ["待上传", "待上传"],
  38. ["已上传", "已上传"]
  39. ]
  40. }),
  41. getCondition: function(v) {
  42. if(v == 'all') {
  43. return '1=1'
  44. }else {
  45. return 'ifnull(b2bStatus,\'待上传\')=' + '\'' + v + '\'';
  46. }
  47. }
  48. }, {
  49. xtype: 'checkbox',
  50. name: 'status',
  51. fieldLabel: '我的产品库',
  52. columnWidth: 0.2,
  53. getCondition: function(v) {
  54. if(v) {
  55. return 'status=' + Number(v);
  56. }else {
  57. return '1=1';
  58. }
  59. }
  60. }],
  61. toolButtons: [{
  62. xtype: 'button',
  63. text: '上传公司产品',
  64. handler: function() {
  65. me.onUpload();
  66. }
  67. }],
  68. gridConfig: {
  69. dataUrl: me.dataUrl,
  70. actionColumn: [],
  71. selModel: {
  72. type: 'cellmodel'
  73. },
  74. hiddenTools: true,
  75. data: [{
  76. }],
  77. columns : [{
  78. text: '物料编号',
  79. dataIndex: 'prodCode',
  80. width: 150
  81. }, {
  82. text: '品牌',
  83. dataIndex: 'prodBrand',
  84. width: 100
  85. }, {
  86. text: '名称',
  87. dataIndex: 'prodName',
  88. width: 150
  89. }, {
  90. text: '型号',
  91. dataIndex: 'prodOrispeccode',
  92. width: 200
  93. }, {
  94. text: '规格',
  95. dataIndex: 'prodSpec',
  96. width: 200
  97. }, {
  98. text: '单位',
  99. width: 65.0,
  100. dataIndex: 'prodUnit'
  101. }, {
  102. text: '上传状态',
  103. dataIndex: 'b2bStatus',
  104. renderer: function(v, m, r) {
  105. return v || '待上传';
  106. }
  107. }, {
  108. text: '我的产品',
  109. dataIndex: 'status',
  110. xtype: 'actioncolumn',
  111. align : 'center',
  112. items: [{
  113. iconCls:'',
  114. getClass: function(v, meta, rec) {
  115. if(rec.get('status')){
  116. return 'x-grid-checkcolumn-checked-btn';
  117. }else{
  118. return 'x-grid-checkcolumn-btn';
  119. }
  120. },
  121. handler: function(view, rowIndex, colIndex) {
  122. var rec = view.getStore().getAt(rowIndex);
  123. // 禁用/启用
  124. var grid = this.ownerCt.ownerCt;
  125. var params = {
  126. prodId: rec.get('prodId'),
  127. prodCode: rec.get('prodCode'),
  128. operate: new Number(!rec.get('status'))
  129. };
  130. grid.setLoading(true);
  131. saas.util.BaseUtil.request({
  132. // url: 'http://10.1.80.23:8560/api/document/product/prodStorage/saler',
  133. url: '/api/document/product/prodStorage/saler',
  134. params: JSON.stringify(params),
  135. method: 'POST',
  136. })
  137. .then(function(localJson) {
  138. grid.setLoading(false);
  139. if(localJson.success){
  140. saas.util.BaseUtil.showSuccessToast('操作成功');
  141. grid.store.load();
  142. }
  143. })
  144. .catch(function(e) {
  145. grid.setLoading(false);
  146. saas.util.BaseUtil.showErrorToast('操作失败: ' + e.message);
  147. });
  148. }
  149. }]
  150. }]
  151. },
  152. });
  153. this.callParent(arguments);
  154. },
  155. onUpload: function() {
  156. var me = this;
  157. me.setLoading(true);
  158. saas.util.BaseUtil.request({
  159. url: '/api/document/product/b2b/upload',
  160. method: 'POST',
  161. }).then(function(res) {
  162. me.setLoading(false);
  163. saas.util.BaseUtil.showSuccessToast('上传成功');
  164. me.refresh();
  165. }).catch(function(e) {
  166. me.setLoading(false);
  167. saas.util.BaseUtil.showErrorToast('上传失败: ' + e.message);
  168. });
  169. },
  170. });