ShowForm.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Ext.define('erp.view.crm.customercare.ShowForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpShowForm',
  4. layout : 'column',
  5. winurl:'',
  6. id:'showform',
  7. title:'',
  8. caller:'',
  9. formCondition:'',
  10. gridCondition:'',
  11. autoScroll : true,
  12. buttons: [{
  13. text: '编辑',
  14. handler:function(){
  15. var form=this.up('form');
  16. var s=basePath+form.winurl+'?formCondition='+form.formCondition+'&girdCondition='+form.girdCondition;//Ext.getCmp('mt_id').value;
  17. var html='<iframe width=100% height=100% src="'+s+'"/>';
  18. var panels=Ext.ComponentQuery.query('.erpDatalistGridPanel2');
  19. var win=new Ext.window.Window({
  20. height:500,
  21. width:800,
  22. modal:true,
  23. listeners : {
  24. close : function(){
  25. form.getColumnsAndStore();
  26. Ext.Array.each(panels,function(panel){
  27. panel.getColumnsAndStore();
  28. });
  29. }
  30. },
  31. html:html});
  32. win.show();
  33. }
  34. }],
  35. getColumnsAndStore:function(){
  36. Ext.Ajax.request({
  37. url : basePath+'common/singleFormItems.action',
  38. params: {
  39. caller: this.caller,//formCondition=mt_idIS3489&gridCondition=ct_cuidIS3489
  40. formCondition: this.formCondition,
  41. condition:this.formCondition,
  42. page: 1,
  43. pageSize: 5
  44. },
  45. method : 'post',
  46. callback : function(options,success,response){
  47. var res = new Ext.decode(response.responseText);
  48. if(res.exceptionInfo != null){
  49. showError(res.exceptionInfo);return;
  50. }
  51. data = Ext.decode(res.data);
  52. var hasData=false;
  53. if(data){
  54. hasData=true;
  55. }
  56. var items=[];
  57. var length=0.5;
  58. if(res.items.length>12){
  59. length=0.3;
  60. }
  61. Ext.each(res.items,function(item){
  62. var i={};
  63. i.xtype='displayfield';
  64. i.columnWidth=length;
  65. if(item.xtype=='htmleditor'){
  66. i.columnWidth=1;
  67. }else if(item.xtype=='hidden'){
  68. i.xtype='hidden';
  69. }
  70. i.fieldLabel=item.fieldLabel;
  71. i.name=item.name;
  72. if(hasData){
  73. i.value=data[item.name];
  74. }
  75. items.push(i);
  76. });
  77. Ext.getCmp('showform').removeAll();
  78. Ext.getCmp('showform').add(items);
  79. }
  80. });
  81. },
  82. initComponent : function(){
  83. this.formCondition=/id/g.test(formCondition)?formCondition:formCondition.split('=')[0]+"='"+formCondition.split('=')[1]+"'";
  84. this.getColumnsAndStore();
  85. this.callParent(arguments);
  86. }
  87. });