DataList.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Created by zhouy on 2018/10/18.
  3. */
  4. Ext.define('trade.saas.view.document.warehouse.DataList', {
  5. extend: 'saas.view.document.kind.Kind',
  6. xtype: 'document-warehouse-datalist',
  7. viewModel: 'document-warehouse-datalist',
  8. defaultType:'warehouse',
  9. windowType:'document-warehouse-window',
  10. _openUrl:'/api/document/warehouse/open',
  11. _closeUrl:'/api/document/warehouse/close',
  12. tbar: ['->',{
  13. xtype:'button',
  14. text:'新增',
  15. listeners: {
  16. click: 'onAdd'
  17. }
  18. },{
  19. xtype:'button',
  20. text:'刷新',
  21. listeners: {
  22. click: 'onRefresh'
  23. }
  24. }],
  25. etc:{
  26. warehouse:{
  27. columns: [{
  28. text: '仓库编号',
  29. dataIndex: 'wh_code',
  30. width: 150
  31. },{
  32. text: '仓库名称',
  33. dataIndex: 'wh_description',
  34. width: 200
  35. },{
  36. text: '仓库类型',
  37. dataIndex: 'wh_type',
  38. width: 110
  39. },{
  40. text: '仓库状态码',
  41. dataIndex: 'wh_status',
  42. hidden:true,
  43. },{
  44. text: '仓库状态',
  45. dataIndex: 'wh_statuscode',
  46. width:90,
  47. xtype: 'actioncolumn',
  48. align : 'center',
  49. items: [{
  50. iconCls:'',
  51. getClass: function(v, meta, rec) {
  52. if(rec.get('wh_statuscode')=='ENABLE'){
  53. return 'x-grid-checkcolumn-checked-btn';
  54. }else{
  55. return 'x-grid-checkcolumn-btn';
  56. }
  57. },
  58. handler: function(view, rowIndex, colIndex) {
  59. var rec = view.getStore().getAt(rowIndex);
  60. var type=rec.get('wh_statuscode')=='ENABLE'?true:false;
  61. // 禁用/启用
  62. var form = this.ownerCt.ownerCt.ownerCt;
  63. var grid = this.ownerCt.ownerCt;
  64. saas.util.BaseUtil.request({
  65. url: (!type?form._openUrl:form._closeUrl)+'/'+rec.get('id'),
  66. params: '',
  67. method: 'POST',
  68. })
  69. .then(function(localJson) {
  70. if(localJson.success){
  71. saas.util.BaseUtil.showSuccessToast('操作成功');
  72. grid.store.load();
  73. }
  74. })
  75. .catch(function(e) {
  76. saas.util.BaseUtil.showErrorToast('操作失败: ' + e.message);
  77. });
  78. }
  79. }]
  80. }],
  81. keyField:'id',
  82. reqUrl: '/api/document/warehouse/save',
  83. delUrl: '/api/document/warehouse/delete'
  84. }
  85. },
  86. listeners:{
  87. afterrender:function(p){
  88. p.getViewModel().setData({title:'仓库'});
  89. }
  90. }
  91. })