SplitTextField.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * RadioGroup
  3. */
  4. Ext.define('erp.view.core.form.SplitTextField', {
  5. extend: 'Ext.form.FieldContainer',
  6. alias: 'widget.splittextfield',
  7. layout: 'column',
  8. baseCls: 'x-field',//fieldContainer默认为x-component x-container x-container-default
  9. initComponent : function(){
  10. this.callParent(arguments);
  11. var me = this;
  12. var cw = me.columnWidth;
  13. // var logic = this.logic;
  14. me.insert(0,{
  15. xtype : 'textfield',
  16. name : me.name,
  17. readOnly : me.readOnly,
  18. columnWidth : 0.7,
  19. // cls:'form-field-gray',
  20. cls:me.cls,
  21. fieldStyle : me.fieldStyle
  22. // fieldStyle:'background:#FFFAFA;color:#515151;'
  23. // fieldStyle:'background:#f1f1f1;border: none;border-right: 2px solid #c6c6c6;border-left: 2px solid #c6c6c6;'
  24. });
  25. me.insert(1,{
  26. xtype : 'label',
  27. columnWidth : 0.3,
  28. text : me.logic
  29. });
  30. },
  31. listeners: {
  32. afterrender: function(){//去掉fieldContainer默认的高度和滚动样式
  33. this.getEl().dom.childNodes[1].style.height = 22;
  34. this.getEl().dom.childNodes[1].style.overflow = 'hidden';
  35. }
  36. },
  37. isValid: function(){
  38. return this.items.items[0].isValid();
  39. },
  40. setValue: function(value){
  41. this.value=value;
  42. },
  43. isDirty:function(){
  44. return true;
  45. },
  46. setFiledValue:function(field){
  47. var value="";
  48. var items=this.items.items;
  49. for(var i=1;i<items.length;i++){
  50. if(items[i].value){
  51. value+="1;";
  52. }else {
  53. value+="-1;";
  54. }
  55. }
  56. value=value.substring(0,value.length-1);
  57. this.items.items[0].setValue(value);
  58. },
  59. getValue: function(){
  60. return this.value;
  61. },
  62. setReadOnly: function(bool){
  63. var me = this;
  64. console.log(me);
  65. console.log(bool);
  66. // item.setReadOnly(bool);
  67. me.items.items[0].setReadOnly(bool);
  68. },
  69. setFieldStyle: function(style){
  70. this.items.items[0].setFieldStyle(style);
  71. }
  72. });