MyForm.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Ext.define('erp.view.ma.MyForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.myform',
  4. frame : true,
  5. autoScroll : true,
  6. defaultType : 'textfield',
  7. labelSeparator : ':',
  8. layout : 'column',
  9. requires: ['erp.view.core.form.FileField'],
  10. fieldDefaults : {
  11. margin : '2 2 2 2',
  12. fieldStyle : "background:#FFFAFA;color:#515151;",
  13. labelAlign : "right",
  14. msgTarget: 'side',
  15. blankText : $I18N.common.form.blankText
  16. },
  17. initComponent : function(){
  18. this.callParent(arguments);
  19. formCondition = this.dataId ? ('fo_id=' + this.dataId) : getUrlParam('formCondition');
  20. formCondition = (formCondition == null) ? "" : formCondition.replace(/IS/g,"=");
  21. var type=getUrlParam('type');
  22. if(type&&type=='crm'){
  23. var cond=getUrlParam('cond');
  24. cond=(cond==null)?'':cond.replace(/IS/g,"=");
  25. this.getItemsAndButtons({caller: 'Reporttemplate', condition: cond});
  26. }else{
  27. this.getItemsAndButtons({caller: this.caller||'Form', condition: formCondition});
  28. }
  29. },
  30. getItemsAndButtons: function(param){
  31. var me = this, main = parent.Ext.getCmp("content-panel");
  32. if(main) {
  33. main.getActiveTab().setLoading(true);
  34. }
  35. Ext.Ajax.request({//拿到form的items
  36. url : basePath + "common/singleFormItems.action",
  37. params: param,
  38. method : 'post',
  39. callback : function(options,success,response){
  40. if(main) {
  41. main.getActiveTab().setLoading(false);
  42. }
  43. var res = new Ext.decode(response.responseText);
  44. me.tablename = res.tablename;
  45. if(res.items) {
  46. var data = res.data ? Ext.decode(res.data) : {};
  47. Ext.each(res.items, function(item){
  48. delete item.id;
  49. if(screen.width >= 1280){//根据屏幕宽度,调整列显示宽度
  50. if(item.columnWidth > 0 && item.columnWidth <= 0.34){
  51. item.columnWidth = 0.25;
  52. } else if(item.columnWidth > 0.34 && item.columnWidth <= 0.67){
  53. item.columnWidth = 0.5;
  54. }
  55. }
  56. if(res.data && item.name) {
  57. item.value = data[item.name];
  58. }
  59. });
  60. me.add(res.items);
  61. }
  62. }
  63. });
  64. }
  65. });