package com.ecep.contract.controller.department;


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.AbstManagerWindowController;
import com.ecep.contract.model.Department;
import com.ecep.contract.model.Employee;
import com.ecep.contract.service.DepartmentService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.DepartmentViewModel;

import javafx.event.ActionEvent;
import javafx.scene.control.TableColumn;
import javafx.stage.Stage;

@Lazy
@Scope("prototype")
@Component
@FxmlPath(value = "/ui/employee/department-manager.fxml")
public class DepartmentManagerWindowController
        extends AbstManagerWindowController<Department, DepartmentViewModel, DepartmentManagerSkin> {

    public TableColumn<DepartmentViewModel, Number> idColumn;
    public TableColumn<DepartmentViewModel, String> nameColumn;
    public TableColumn<DepartmentViewModel, String> codeColumn;
    public TableColumn<DepartmentViewModel, Employee> leaderColumn;
    public TableColumn<DepartmentViewModel, Boolean> activeColumn;

    @Autowired
    DepartmentService departmentService;

    @Override
    public void show(Stage stage) {
        super.show(stage);
        getTitle().set("部门管理");
    }

    @Override
    protected DepartmentManagerSkin createDefaultSkin() {
        return new DepartmentManagerSkin(this);
    }

    public void onReBuildFilesAction(ActionEvent event) {

    }

    public void onBaseTableRefreshAction(ActionEvent event) {
        getSkin().loadTableDataSet(true);
    }

    public void onCreateNewAction(ActionEvent event) {
        getSkin().onTableCreateNewAction(event);
    }

    @Override
    public DepartmentService getViewModelService() {
        return departmentService;
    }
}
