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. defaultType:'address',
  9. windowType:'document-address-window',
  10. _openUrl:'/api/document/address/setDefault',
  11. tbar: ['->',{
  12. xtype:'button',
  13. text:'新增',
  14. listeners: {
  15. click: 'onAdd'
  16. }
  17. },{
  18. xtype:'button',
  19. text:'刷新',
  20. listeners: {
  21. click: 'onRefresh'
  22. }
  23. }],
  24. etc:{
  25. address:{
  26. columns: [{
  27. text: '地址名称',
  28. dataIndex: 'ad_address',
  29. flex: 1
  30. },{
  31. text: '采购默认地址',
  32. dataIndex: 'ad_default',
  33. width:160,
  34. xtype: 'actioncolumn',
  35. align : 'center',
  36. items: [{
  37. iconCls:'',
  38. getClass: function(v, meta, rec) {
  39. if(rec.get('ad_default')==1){
  40. return 'x-grid-checkcolumn-checked-btn';
  41. }else{
  42. return 'x-grid-checkcolumn-btn';
  43. }
  44. },
  45. handler: function(view, rowIndex, colIndex) {
  46. var rec = view.getStore().getAt(rowIndex);
  47. var type=rec.get('ad_default')==1?true:false;
  48. if(type){
  49. saas.util.BaseUtil.showErrorToast('请启用其它未设置的地址');
  50. return;
  51. }
  52. // 启用
  53. var form = this.ownerCt.ownerCt.ownerCt;
  54. var grid = this.ownerCt.ownerCt;
  55. saas.util.BaseUtil.request({
  56. url: form._openUrl+'/'+rec.get('id'),
  57. method: 'POST',
  58. })
  59. .then(function(localJson) {
  60. if(localJson.success){
  61. saas.util.BaseUtil.showSuccessToast('操作成功');
  62. grid.store.load();
  63. }
  64. })
  65. .catch(function(res) {
  66. console.error(res);
  67. saas.util.BaseUtil.showErrorToast('操作失败: ' + res.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. })