DataList.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * Created by zhouy on 2018/10/18.
  3. */
  4. Ext.define('saas.view.document.address.DataList', {
  5. extend: 'saas.view.document.kind.Kind',
  6. xtype: 'document-address-datalist',
  7. viewModel: 'document-address-datalist',
  8. controller:'document-address-datalist',
  9. defaultType:'address',
  10. windowType:'document-address-window',
  11. _openUrl:'/api/document/address/setDefault',
  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. address:{
  27. columns: [{
  28. text: '地址名称',
  29. dataIndex: 'ad_address',
  30. flex: 1
  31. },{
  32. text: '采购默认地址',
  33. dataIndex: 'ad_default',
  34. width:160,
  35. xtype: 'actioncolumn',
  36. align : 'center',
  37. items: [{
  38. iconCls:'',
  39. getClass: function(v, meta, rec) {
  40. if(rec.get('ad_default')==1){
  41. return 'x-grid-checkcolumn-checked-btn';
  42. }else{
  43. return 'x-grid-checkcolumn-btn';
  44. }
  45. },
  46. handler: function(view, rowIndex, colIndex) {
  47. var rec = view.getStore().getAt(rowIndex);
  48. var type=rec.get('ad_default')==1?true:false;
  49. if(type){
  50. saas.util.BaseUtil.showErrorToast('请启用其它未设置的地址');
  51. return;
  52. }
  53. // 启用
  54. var form = this.ownerCt.ownerCt.ownerCt;
  55. var grid = this.ownerCt.ownerCt;
  56. saas.util.BaseUtil.request({
  57. url: form._openUrl+'/'+rec.get('id'),
  58. method: 'POST',
  59. })
  60. .then(function(localJson) {
  61. if(localJson.success){
  62. saas.util.BaseUtil.showSuccessToast('操作成功');
  63. grid.store.load();
  64. }
  65. })
  66. .catch(function(e) {
  67. saas.util.BaseUtil.showErrorToast('操作失败: ' + e.message);
  68. });
  69. }
  70. }]
  71. }],
  72. keyField:'id',
  73. reqUrl: '/api/document/address/save',
  74. delUrl: '/api/document/address/delete'
  75. },
  76. },
  77. listeners:{
  78. afterrender:function(p){
  79. p.getViewModel().setData({title:'采购交货地址'});
  80. }
  81. }
  82. })