数据报表

master
spf 7 months ago
parent feb70545b9
commit 6f7b275d85

@ -8,6 +8,7 @@ import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.stage.Stage; import javafx.stage.Stage;
import view.InboundView; import view.InboundView;
import view.InventoryReportView;
import view.OutboundView; import view.OutboundView;
public class Main extends Application { public class Main extends Application {
@ -146,6 +147,11 @@ public class Main extends Application {
MenuItem inventoryReportItem = new MenuItem("库存报表"); MenuItem inventoryReportItem = new MenuItem("库存报表");
MenuItem logItem = new MenuItem("操作日志"); MenuItem logItem = new MenuItem("操作日志");
reportMenu.getItems().addAll(inventoryReportItem, logItem); reportMenu.getItems().addAll(inventoryReportItem, logItem);
// 为库存报表菜单项添加事件处理
inventoryReportItem.setOnAction(e -> showInventoryReportView());
menuBar.getMenus().addAll(systemMenu, inventoryMenu, goodsMenu, reportMenu);
// 为入库管理菜单项添加事件处理 // 为入库管理菜单项添加事件处理
inboundItem.setOnAction(e -> showInboundView()); inboundItem.setOnAction(e -> showInboundView());
@ -216,6 +222,11 @@ public class Main extends Application {
OutboundView outboundView = new OutboundView(); OutboundView outboundView = new OutboundView();
contentArea.setCenter(outboundView); contentArea.setCenter(outboundView);
} }
// 添加显示库存报表视图的方法
private void showInventoryReportView() {
InventoryReportView inventoryReportView = new InventoryReportView();
contentArea.setCenter(inventoryReportView);
}
public static void main(String[] args) { public static void main(String[] args) {
launch(args); launch(args);
} }

@ -70,6 +70,18 @@ public class DataManager {
inventory.put(goods.getId(), 0); inventory.put(goods.getId(), 0);
} }
} }
public static List<InventoryReport> generateInventoryReport() {
List<InventoryReport> reports = new ArrayList<>();
// 这里可以调用数据库或其他数据源获取库存数据
// 示例数据
reports.add(new InventoryReport("G001", "商品A", 100, "供应商A", "无"));
reports.add(new InventoryReport("G002", "商品B", 200, "供应商B", "无"));
reports.add(new InventoryReport("G003", "商品C", 150, "供应商C", "无"));
return reports;
}
public Goods getGoods(String id) { public Goods getGoods(String id) {
return goodsMap.get(id); return goodsMap.get(id);

@ -0,0 +1,29 @@
package model;
public class InventoryReport {
private String goodsId;
private String goodsName;
private int totalQuantity;
private String supplier;
private String remark;
public InventoryReport(String goodsId, String goodsName, int totalQuantity, String supplier, String remark) {
this.goodsId = goodsId;
this.goodsName = goodsName;
this.totalQuantity = totalQuantity;
this.supplier = supplier;
this.remark = remark;
}
public String getGoodsId() { return goodsId; }
public void setGoodsId(String goodsId) { this.goodsId = goodsId; }
public String getGoodsName() { return goodsName; }
public void setGoodsName(String goodsName) { this.goodsName = goodsName; }
public int getTotalQuantity() { return totalQuantity; }
public void setTotalQuantity(int totalQuantity) { this.totalQuantity = totalQuantity; }
public String getSupplier() { return supplier; }
public void setSupplier(String supplier) { this.supplier = supplier; }
public String getRemark() { return remark; }
public void setRemark(String remark) { this.remark = remark; }
}

@ -0,0 +1,64 @@
package view;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.control.cell.PropertyValueFactory;
import model.InventoryReport;
import model.DataManager;
import java.util.List;
public class InventoryReportView extends BorderPane {
private TableView<InventoryReport> tableView;
public InventoryReportView() {
initializeUI();
}
private void initializeUI() {
// 顶部标题区域
Label titleLabel = new Label("库存报表");
titleLabel.setStyle("-fx-font-size: 20px; -fx-font-weight: bold;");
titleLabel.setAlignment(Pos.CENTER);
setTop(titleLabel);
// 中间表格区域
tableView = createTableView();
setCenter(tableView);
// 加载库存报表数据
loadInventoryReportData();
}
private TableView<InventoryReport> createTableView() {
TableView<InventoryReport> table = new TableView<>();
TableColumn<InventoryReport, String> goodsIdCol = new TableColumn<>("货物编号");
goodsIdCol.setCellValueFactory(new PropertyValueFactory<>("goodsId"));
TableColumn<InventoryReport, String> goodsNameCol = new TableColumn<>("货物名称");
goodsNameCol.setCellValueFactory(new PropertyValueFactory<>("goodsName"));
TableColumn<InventoryReport, Integer> totalQuantityCol = new TableColumn<>("总数量");
totalQuantityCol.setCellValueFactory(new PropertyValueFactory<>("totalQuantity"));
TableColumn<InventoryReport, String> supplierCol = new TableColumn<>("供应商");
supplierCol.setCellValueFactory(new PropertyValueFactory<>("supplier"));
TableColumn<InventoryReport, String> remarkCol = new TableColumn<>("备注");
remarkCol.setCellValueFactory(new PropertyValueFactory<>("remark"));
table.getColumns().addAll(goodsIdCol, goodsNameCol, totalQuantityCol, supplierCol, remarkCol);
return table;
}
private void loadInventoryReportData() {
List<InventoryReport> reports = DataManager.generateInventoryReport();
tableView.setItems(FXCollections.observableArrayList(reports));
}
}
Loading…
Cancel
Save