package com.ecep.contract.controller.customer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.util.FxmlPath;
import com.ecep.contract.controller.tab.SalesOrderTabSkinBase;
import com.ecep.contract.controller.tab.SalesOrderTabSkinBillVoucher;
import com.ecep.contract.controller.tab.SalesOrderTabSkinItems;
import com.ecep.contract.model.SalesOrder;
import com.ecep.contract.service.SaleOrdersService;
import com.ecep.contract.vm.SalesOrderViewModel;

import javafx.scene.control.Button;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.stage.Window;

@Lazy
@Scope("prototype")
@Component
@FxmlPath("/ui/contract/sale-orders.fxml")
public class SalesOrderWindowController extends AbstEntityController<SalesOrder, SalesOrderViewModel> {
    private static final Logger logger = LoggerFactory.getLogger(SalesOrderWindowController.class);
    public TabPane tabPane;
    public Button saveBtn;

    public Tab baseInfoTab;
    public Tab itemTab;
    public Tab billVoucherTab;

    public TextField codeField;
    public TextField employeeField;
    public TextField verifierDateField;
    public TextField verifierField;
    public TextField makeDateField;
    public TextField makerField;
    public TextArea descriptionField;


    public static void show(SalesOrderViewModel viewModel, Window window) {
        show(SalesOrderWindowController.class, viewModel, window);
    }

    @Override
    public void show(Stage stage) {
        super.show(stage);
        getTitle().set("销售订单详情");
    }

    @Override
    protected void registerTabSkins() {
        registerTabSkin(baseInfoTab, tab -> new SalesOrderTabSkinBase(this));
        registerTabSkin(itemTab, tab -> new SalesOrderTabSkinItems(this));
        registerTabSkin(billVoucherTab, tab -> new SalesOrderTabSkinBillVoucher(this));
    }

    @Override
    public SaleOrdersService getViewModelService() {
        return getCachedBean(SaleOrdersService.class);
    }
}
