// 假设 CurrencyBase 的类型定义
class CurrencyBase {
    public Accuracy: number = 0;
    public CurrencySymbol: string = "";
    public CurrencySymbolType: any;
    public _initTxtLength: number = 0;
    public _formatType: string = "";
    public _txtValue: string = "";

    public OnPreviewKeyDown(e: any) {}
    public OnTextChanged(e: any) {}
    public OnGotFocus(e: any) {}
    public OnLostFocus(e: any) {}
}

// 假设 CurrencySymbolType 的枚举定义
enum CurrencySymbolType {
    UserSetting
}

export class CurrencyRateEditor extends CurrencyBase {
    constructor() {
        super();
        // 禁用输入法，Vue 中没有直接对应方法，这里注释说明
        // 可以在组件中通过 input 元素的相关属性实现
        this.Accuracy = 6;
        this.updateText();
        this.CurrencySymbol = "%";
        this.CurrencySymbolType = CurrencySymbolType.UserSetting;
    }

    private updateText() {
        this._txtValue = this.GetTxtValue();
    }

    public OnPreviewKeyDown(e: any) {
        this._initTxtLength = this.GetInitTxtLength();
        this._formatType = this.GetFormatType();
        super.OnPreviewKeyDown(e);
    }

    public OnTextChanged(e: any) {
        this.updateText();
        this._formatType = this.GetFormatType();
        super.OnTextChanged(e);
    }

    public OnGotFocus(e: any) {
        this.updateText();
        super.OnGotFocus(e);
    }

    public OnLostFocus(e: any) {
        this.updateText();
        this._formatType = this.GetFormatType();
        super.OnLostFocus(e);
    }

    private GetTxtValue(): string {
        return "0.".padEnd(this.Accuracy + 2, '0');
    }

    private GetFormatType(): string {
        return `{0:F${this.Accuracy}}`;
    }

    private GetInitTxtLength(): number {
        return this.Accuracy + 2;
    }
}