package com.ecep.contract.controller.bank.account;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.model.CompanyBankAccount;
import com.ecep.contract.service.CompanyBankAccountService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.CompanyBankAccountViewModel;

import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.stage.Window;
import javafx.stage.WindowEvent;

@Lazy
@Scope("prototype")
@Component
@FxmlPath("/ui/company/bank-account.fxml")
public class BankAccountWindowController extends AbstEntityController<CompanyBankAccount, CompanyBankAccountViewModel> {
    public BorderPane root;
    public TabPane tabPane;

    public Tab baseInfoTab;
    public TextField companyField;
    public Button relativeCompanyBtn;
    public TextField bankField;
    public TextField openingBankField;
    public TextField bankAccountField;
    public TextField createdField;
    public TextArea descriptionField;
    public Label versionLabel;

    public Tab entityTab;


    public static void show(CompanyBankAccountViewModel viewModel, Window window) {
        show(BankAccountWindowController.class, viewModel, window);
    }

    @Autowired
    private CompanyBankAccountService bankAccountService;

    @Override
    public void onShown(WindowEvent event) {
        super.onShown(event);
        getTitle().set("[" + viewModel.getId().get() + "] 银行账户详情");
    }

    @Override
    protected void registerTabSkins() {
        registerTabSkin(baseInfoTab, tab -> new BankAccountBaseTabSkin(this));
    }

    @Override
    public CompanyBankAccountService getViewModelService() {
        return bankAccountService;
    }

}
