ChildForm.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Created by zhouy on 2018/10/18.
  3. */
  4. Ext.define('KitchenSink.view.binding.ChildForm', {
  5. extend: 'Ext.window.Window',
  6. xtype: 'document-kind-childwin',
  7. layout: 'fit',
  8. modal: true,
  9. width: 400,
  10. height: 220,
  11. listeners:{
  12. show:function(w){
  13. if(w.record){
  14. w.down('form').loadRecord(w.record);
  15. }
  16. }
  17. },
  18. initComponent:function(){
  19. var me=this;
  20. Ext.apply(me,{
  21. items:me.setFormItems()
  22. });
  23. me.callParent();
  24. },
  25. etc:{
  26. customerkind:{
  27. items:[{
  28. xtype:'hidden',
  29. name:'ck_id'
  30. },{
  31. xtype:'textfield',
  32. name:'ck_kind',
  33. allowBlank:false,
  34. fieldLabel:'类型'
  35. }],
  36. keyField:'ck_id',
  37. saveUrl:''
  38. },
  39. vendorkind:{
  40. items:[{
  41. xtype:'hidden',
  42. name:'vk_id'
  43. },{
  44. xtype:'textfield',
  45. name:'vk_kind',
  46. allowBlank:false,
  47. fieldLabel:'类型'
  48. }],
  49. },
  50. productkind:{
  51. items:[{
  52. xtype:'hidden',
  53. name:'pk_id'
  54. },{
  55. xtype:'textfield',
  56. name:'pk_kind',
  57. allowBlank:false,
  58. fieldLabel:'类型'
  59. }],
  60. },
  61. inoutkind:{
  62. }
  63. },
  64. setFormItems:function() {
  65. var me = this, kind = me.dataKind;
  66. var conf = {
  67. xtype: 'form',
  68. bodyPadding: 10,
  69. border: false,
  70. modelValidation: true,
  71. layout: {
  72. type: 'vbox',
  73. align: 'stretch'
  74. },
  75. defaults: {
  76. xtype: 'textfield'
  77. },
  78. buttons: [{
  79. text: '保存',
  80. formBind:true,
  81. handler: me.onSave,
  82. scope:me
  83. }, {
  84. text: '取消',
  85. handler: me.onCancel,
  86. scope:me
  87. }]
  88. };
  89. return Ext.apply(conf, me.etc[kind]);
  90. },
  91. onSave:function(){
  92. var form=this.down('form');
  93. alert('save');
  94. },
  95. onCancel:function(){
  96. alert('cancel');
  97. this.hide();
  98. }
  99. });