DataList.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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(res) {
  67. console.error(res);
  68. saas.util.BaseUtil.showErrorToast('操作失败: ' + res.message);
  69. });
  70. }
  71. }]
  72. }],
  73. keyField:'id',
  74. reqUrl: '/api/document/address/save',
  75. delUrl: '/api/document/address/delete'
  76. },
  77. },
  78. listeners:{
  79. afterrender:function(p){
  80. p.getViewModel().setData({title:'采购地址'});
  81. }
  82. }
  83. })