feat: 添加功能模块相关字段和界面优化

- 在FUNC表中添加CONTROLLER、ICON和DESCRIPTION字段
- 重构角色管理相关类名和路径
- 优化公司表格单元格显示逻辑
- 添加功能权限管理界面
- 优化日志配置和FXML文件引用
- 移除冗余代码和注释
This commit is contained in:
danyz
2025-08-23 18:39:05 +08:00
parent 6cbe3f37ee
commit 8135acf16a
52 changed files with 1015 additions and 511 deletions

View File

@@ -1,31 +1,5 @@
package com.ecep.contract.manager.ui;
import com.ecep.contract.manager.ds.other.model.IdentityEntity;
import com.ecep.contract.manager.ds.other.vo.IdentityViewModel;
import com.ecep.contract.manager.util.TableViewUtils;
import com.ecep.contract.manager.util.UITools;
import javafx.application.Platform;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.util.converter.NumberStringConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -34,18 +8,46 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import com.ecep.contract.manager.ds.other.model.IdentityEntity;
import com.ecep.contract.manager.ds.other.vo.IdentityViewModel;
import com.ecep.contract.manager.util.TableViewUtils;
import com.ecep.contract.manager.util.UITools;
import javafx.application.Platform;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.util.converter.NumberStringConverter;
/**
* @param <T> Entity 的类型
* @param <TV> Entity 对应的ViewModel
* @param <Skin> Skin 的类型
* @param <C>
*/
public abstract class AbstEntityManagerSkin<
T extends IdentityEntity,
TV extends IdentityViewModel<T>,
Skin extends ManagerSkin,
C extends AbstManagerWindowController<T, TV, Skin>
> implements ManagerSkin, TableTabSkin<T, TV>, EditableEntityTableTabSkin<T, TV> {
public abstract class AbstEntityManagerSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>, Skin extends ManagerSkin, C extends AbstManagerWindowController<T, TV, Skin>>
implements ManagerSkin, TableTabSkin<T, TV>, EditableEntityTableTabSkin<T, TV> {
private static final Logger logger = LoggerFactory.getLogger(AbstEntityManagerSkin.class);
/**
*
@@ -80,7 +82,6 @@ public abstract class AbstEntityManagerSkin<
UITools.showExceptionAndWait(message, ex);
}
public Locale getLocale() {
return controller.getLocale();
}
@@ -102,7 +103,6 @@ public abstract class AbstEntityManagerSkin<
});
}
private void onShown() {
if (loadedFuture == null) {
loadedFuture = runAsync(() -> {
@@ -135,7 +135,7 @@ public abstract class AbstEntityManagerSkin<
});
loadTableDataSet(true);
}).exceptionally(this::handleException);
});
}
}
@@ -156,14 +156,23 @@ public abstract class AbstEntityManagerSkin<
currentPageNumber.addListener(this::currentPageNumberListener);
//
controller.currentPageNumberField.textProperty().bindBidirectional(currentPageNumber, new NumberStringConverter());
controller.currentPageNumberField.textProperty().bindBidirectional(currentPageNumber,
new NumberStringConverter());
controller.previousPageBtn.setOnAction(event -> {
currentPageable = currentPageable.previous();
loadTableDataSet(true);
try {
currentPageable = currentPageable.previous();
loadTableDataSet(true);
} catch (Exception e) {
logger.warn("previous page error", e);
}
});
controller.nextPageBtn.setOnAction(event -> {
currentPageable = currentPageable.next();
loadTableDataSet(true);
try {
currentPageable = currentPageable.next();
loadTableDataSet(true);
} catch (Exception e) {
logger.warn("next page error", e);
}
});
}
@@ -275,7 +284,6 @@ public abstract class AbstEntityManagerSkin<
return false;
}
protected T createNewEntity(TV row) {
ViewModelService<T, TV> service = getViewModelService();
if (service != null) {
@@ -341,7 +349,7 @@ public abstract class AbstEntityManagerSkin<
try {
_reloadTableData().thenRun(() -> loadTableDataSetFuture = null).exceptionally(this::handleException);
} catch (Exception ex) {
handleException(ex);
handleException("加载表格数据出错", ex);
}
}, reloadNow ? 0 : 618, TimeUnit.MILLISECONDS);
}
@@ -370,13 +378,26 @@ public abstract class AbstEntityManagerSkin<
}
protected void updateTableDataSet(List<TV> models) {
long timeMillis = System.currentTimeMillis();
dataSet.setAll(models);
long timeCost = System.currentTimeMillis() - timeMillis;
if (logger.isDebugEnabled()) {
logger.debug("update table dataSet cost: {} ms", timeCost);
}
}
protected List<TV> loadTableData() {
Specification<T> spec = getSpecification();
ViewModelService<T, TV> service = getViewModelService();
long timeMillis = System.currentTimeMillis();
Page<T> page = service.findAll(spec, getPageable());
long timeCost = System.currentTimeMillis() - timeMillis;
if (logger.isDebugEnabled()) {
logger.debug("load table data cost: {} ms", timeCost);
}
if (timeCost > 1000) {
controller.setStatus("used " + timeCost + " ms");
}
updateFooter(page);
return page.map(service::from).toList();
}
@@ -416,7 +437,8 @@ public abstract class AbstEntityManagerSkin<
controller.previousPageBtn.setDisable(!page.hasPrevious());
controller.nextPageBtn.setDisable(!page.hasNext());
currentPageNumber.set(page.getNumber());
controller.setStatus((page.getNumber() + 1) + "/" + page.getTotalPages() + " 页, 总 " + page.getTotalElements() + "");
controller.setStatus(
(page.getNumber() + 1) + "/" + page.getTotalPages() + " 页, 总 " + page.getTotalElements() + "");
});
}