DataList.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * Created by zhouy on 2018/10/18.
  3. */
  4. Ext.define('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(res) {
  76. console.error(res);
  77. saas.util.BaseUtil.showErrorToast('操作失败: ' + res.message);
  78. });
  79. }
  80. }]
  81. }],
  82. keyField:'id',
  83. reqUrl: '/api/document/warehouse/save',
  84. delUrl: '/api/document/warehouse/delete'
  85. }
  86. },
  87. listeners:{
  88. afterrender:function(p){
  89. p.getViewModel().setData({title:'仓库'});
  90. }
  91. }
  92. })