feat(权限管理): 为角色和功能添加启用状态字段
- 在EMPLOYEE_ROLE表中添加IS_ACTIVE字段,默认值为TRUE - 在EmployeeRole和Function实体类中添加active字段 - 在角色和功能管理界面添加启用状态列和控件 - 实现TaskMonitorCenter与状态栏标签的绑定 - 更新相关ViewModel以支持启用状态 - 配置Maven仓库地址
This commit is contained in:
@@ -74,6 +74,7 @@ public class HomeWindowController extends BaseController {
|
||||
public Button openVendorManagerWindow;
|
||||
public Button openCustomManagerWindow;
|
||||
public TaskProgressView<Task<?>> taskProgressView;
|
||||
public Label taskMonitorLabel;
|
||||
public Label employeeStatusLabel;
|
||||
|
||||
public void initialize() {
|
||||
@@ -99,7 +100,7 @@ public class HomeWindowController extends BaseController {
|
||||
((Label) placeholder).setText("没有运行的任务");
|
||||
|
||||
employeeStatusLabel.textProperty().bind(Desktop.instance.getActiveEmployee().getName());
|
||||
|
||||
Desktop.instance.getTaskMonitorCenter().bindStatusLabel(taskMonitorLabel);
|
||||
Desktop.instance.getActiveEmployee().initialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ public class EmployeeFunctionsManagerWindowController
|
||||
public TableColumn<FunctionViewModel, String> iconColumn;
|
||||
@FXML
|
||||
public TableColumn<FunctionViewModel, String> descriptionColumn;
|
||||
@FXML
|
||||
public TableColumn<FunctionViewModel, Boolean> activeColumn;
|
||||
|
||||
@Override
|
||||
public void show(Stage stage) {
|
||||
|
||||
@@ -29,6 +29,8 @@ public class EmployeeRoleManagerSkin
|
||||
controller.systemAdministratorColumn.setCellFactory(param -> new CheckBoxTableCell<>());
|
||||
controller.managerColumn.setCellValueFactory(param -> param.getValue().getManager());
|
||||
controller.managerColumn.setCellFactory(CheckBoxTableCell.forTableColumn(controller.managerColumn));
|
||||
controller.activeColumn.setCellValueFactory(param -> param.getValue().getActive());
|
||||
controller.activeColumn.setCellFactory(CheckBoxTableCell.forTableColumn(controller.activeColumn));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.ecep.contract.manager.ui.AbstManagerWindowController;
|
||||
import com.ecep.contract.manager.ui.FxmlPath;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@@ -36,6 +37,7 @@ public class EmployeeRoleManagerWindowController
|
||||
public TableColumn<EmployeeRoleViewModel, String> nameColumn;
|
||||
public TableColumn<EmployeeRoleViewModel, Boolean> systemAdministratorColumn;
|
||||
public TableColumn<EmployeeRoleViewModel, Boolean> managerColumn;
|
||||
public TableColumn<EmployeeRoleViewModel, Boolean> activeColumn;
|
||||
|
||||
@Override
|
||||
protected EmployeeRoleManagerSkin createDefaultSkin() {
|
||||
|
||||
@@ -25,5 +25,6 @@ public class EmployeeRoleTabSkinBase extends AbstEmployeeRoleBasedTabSkin implem
|
||||
controller.systemAdministratorField.selectedProperty().bind(viewModel.getSystemAdministrator());
|
||||
}
|
||||
controller.managerField.selectedProperty().bindBidirectional(viewModel.getManager());
|
||||
controller.activeField.selectedProperty().bindBidirectional(viewModel.getActive());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.ecep.contract.manager.ds.other.vo.EmployeeRoleViewModel;
|
||||
import com.ecep.contract.manager.ui.AbstEntityController;
|
||||
import com.ecep.contract.manager.ui.FxmlPath;
|
||||
import com.ecep.contract.manager.ui.ViewModelService;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.Window;
|
||||
@@ -44,6 +46,7 @@ public class EmployeeRoleWindowController extends AbstEntityController<EmployeeR
|
||||
public CheckBox systemAdministratorField;
|
||||
public CheckBox managerField;
|
||||
public DatePicker createdField;
|
||||
@FXML
|
||||
public CheckBox activeField;
|
||||
public Label versionLabel;
|
||||
/*
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ecep.contract.manager.ds.other.vo.FunctionViewModel;
|
||||
import com.ecep.contract.manager.ui.AbstEntityManagerSkin;
|
||||
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.cell.CheckBoxTableCell;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
|
||||
public class FunctionManagerSkin
|
||||
@@ -40,6 +41,9 @@ public class FunctionManagerSkin
|
||||
controller.descriptionColumn.setCellValueFactory(param -> param.getValue().getDescription());
|
||||
controller.descriptionColumn.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
controller.descriptionColumn.setOnEditCommit(this::onDescriptionColumnEditCommit);
|
||||
|
||||
controller.activeColumn.setCellValueFactory(param -> param.getValue().getActive());
|
||||
controller.activeColumn.setCellFactory(CheckBoxTableCell.forTableColumn(controller.activeColumn));
|
||||
}
|
||||
|
||||
private void onNameColumnEditCommit(TableColumn.CellEditEvent<FunctionViewModel, String> event) {
|
||||
|
||||
@@ -26,5 +26,6 @@ public class FunctionTabSkinBase
|
||||
controller.controllerField.textProperty().bindBidirectional(viewModel.getController());
|
||||
controller.iconField.textProperty().bindBidirectional(viewModel.getIcon());
|
||||
controller.descriptionField.textProperty().bindBidirectional(viewModel.getDescription());
|
||||
controller.activeField.selectedProperty().bindBidirectional(viewModel.getActive());
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,8 @@ public class FunctionWindowController extends AbstEntityController<Function, Fun
|
||||
@FXML
|
||||
public TextField descriptionField;
|
||||
@FXML
|
||||
public CheckBox activeField;
|
||||
@FXML
|
||||
public Label versionLabel;
|
||||
|
||||
public static void show(Function function, Window owner) {
|
||||
|
||||
@@ -32,6 +32,11 @@ public class EmployeeRole implements IdentityEntity, NamedEntity {
|
||||
@Column(name = "MANAGER")
|
||||
private boolean manager;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Column(name = "IS_ACTIVE")
|
||||
private boolean active = true;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
|
||||
@JoinTable(
|
||||
|
||||
@@ -16,6 +16,7 @@ public class EmployeeRoleViewModel extends IdentityViewModel<EmployeeRole> {
|
||||
private SimpleStringProperty name = new SimpleStringProperty();
|
||||
private SimpleBooleanProperty systemAdministrator = new SimpleBooleanProperty();
|
||||
private SimpleBooleanProperty manager = new SimpleBooleanProperty();
|
||||
private SimpleBooleanProperty active = new SimpleBooleanProperty();
|
||||
|
||||
public static EmployeeRoleViewModel from(EmployeeRole v) {
|
||||
EmployeeRoleViewModel model = new EmployeeRoleViewModel();
|
||||
@@ -30,6 +31,7 @@ public class EmployeeRoleViewModel extends IdentityViewModel<EmployeeRole> {
|
||||
getName().set(v.getName());
|
||||
getSystemAdministrator().set(v.isSystemAdministrator());
|
||||
getManager().set(v.isManager());
|
||||
getActive().set(v.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,6 +53,10 @@ public class EmployeeRoleViewModel extends IdentityViewModel<EmployeeRole> {
|
||||
v.setManager(getManager().get());
|
||||
modified = true;
|
||||
}
|
||||
if (!Objects.equals(getActive().get(), v.isActive())) {
|
||||
v.setActive(getActive().get());
|
||||
modified = true;
|
||||
}
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.manager.ds.other.model.Function;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -16,6 +17,7 @@ public class FunctionViewModel extends IdentityViewModel<Function> {
|
||||
private SimpleStringProperty controller = new SimpleStringProperty();
|
||||
private SimpleStringProperty icon = new SimpleStringProperty();
|
||||
private SimpleStringProperty description = new SimpleStringProperty();
|
||||
private SimpleBooleanProperty active = new SimpleBooleanProperty();
|
||||
|
||||
public static FunctionViewModel from(Function v) {
|
||||
FunctionViewModel model = new FunctionViewModel();
|
||||
@@ -32,6 +34,7 @@ public class FunctionViewModel extends IdentityViewModel<Function> {
|
||||
getController().set(v.getController());
|
||||
getIcon().set(v.getIcon());
|
||||
getDescription().set(v.getDescription());
|
||||
getActive().set(v.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,6 +60,10 @@ public class FunctionViewModel extends IdentityViewModel<Function> {
|
||||
v.setDescription(description.get());
|
||||
modified = true;
|
||||
}
|
||||
if (active.get() != v.isActive()) {
|
||||
v.setActive(active.get());
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,15 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.ecep.contract.manager.Desktop;
|
||||
import com.ecep.contract.manager.ui.BaseController;
|
||||
import com.ecep.contract.manager.ui.Tasker;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
@@ -150,4 +154,15 @@ public class TaskMonitorCenter {
|
||||
MonitoredTask<T> registerTask = registerTask(task);
|
||||
Desktop.instance.getExecutorService().submit(registerTask);
|
||||
}
|
||||
|
||||
public void bindStatusLabel(Label monitorLabel) {
|
||||
Tooltip tooltip = new Tooltip("当前运行任务数: " + activeTasks.size());
|
||||
monitorLabel.setTooltip(tooltip);
|
||||
activeTasks.addListener((ListChangeListener<MonitoredTask<?>>) change -> {
|
||||
tooltip.setText("当前运行任务数: " + activeTasks.size());
|
||||
});
|
||||
monitorLabel.setOnMouseClicked(event -> {
|
||||
BaseController.show(TaskMonitorViewController.class, monitorLabel.getScene().getWindow());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,8 @@
|
||||
<TextField fx:id="iconField" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||
<Label text="描述" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="descriptionField" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
<Label text="是否启用" GridPane.rowIndex="6"/>
|
||||
<CheckBox fx:id="activeField" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
|
||||
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="11">
|
||||
<children>
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<TableColumn fx:id="controllerColumn" prefWidth="150" text="控制器"/>
|
||||
<TableColumn fx:id="iconColumn" prefWidth="150" text="图标"/>
|
||||
<TableColumn fx:id="descriptionColumn" prefWidth="200" text="备注"/>
|
||||
<TableColumn fx:id="activeColumn" prefWidth="80" text="是否启用"/>
|
||||
</columns>
|
||||
</TableView>
|
||||
<fx:include source="../part-footer.fxml" fx:id="footer"/>
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<Tooltip text="用于解决有些姓名错别字,无法匹配" />
|
||||
</tooltip></Label>
|
||||
<Label text="活跃的" GridPane.rowIndex="5" />
|
||||
<CheckBox fx:id="activeField" disable="true" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||
<CheckBox fx:id="activeField" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||
<CheckBox fx:id="systemAdministratorField" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<CheckBox fx:id="managerField" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
</children>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<TableColumn fx:id="codeColumn" prefWidth="150" text="编号"/>
|
||||
<TableColumn fx:id="systemAdministratorColumn" prefWidth="50" text="系统管理员"/>
|
||||
<TableColumn fx:id="managerColumn" prefWidth="50" text="管理层"/>
|
||||
<TableColumn fx:id="activeColumn" prefWidth="50" text="是否启用"/>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
</ToolBar>
|
||||
<AnchorPane prefHeight="248.0" prefWidth="2239.0" VBox.vgrow="ALWAYS"/>
|
||||
<TaskProgressView fx:id="taskProgressView"/>
|
||||
<HBox>
|
||||
<HBox fx:id="statusBar" spacing="5.0">
|
||||
<children>
|
||||
<Label fx:id="leftStatusLabel" text="Label" wrapText="true"/>
|
||||
<Pane prefHeight="12.0" prefWidth="12.0" HBox.hgrow="ALWAYS"/>
|
||||
@@ -199,6 +199,7 @@
|
||||
<Insets left="6.0"/>
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
<Label fx:id="taskMonitorLabel" text="任务监控"></Label>
|
||||
<Label fx:id="employeeStatusLabel" layoutX="711.0" layoutY="10.0" text="管理员" wrapText="true"
|
||||
HBox.hgrow="SOMETIMES">
|
||||
<HBox.margin>
|
||||
|
||||
Reference in New Issue
Block a user