CustomWindowNewDemo.java 6.74 KB
package cn.csbr.app.gui.page;

import cn.csbr.app.gui.page.useAndBackTab.*;
import cn.csbr.app.gui.util.CsButtonGroup;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import org.controlsfx.control.PropertySheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component
public class CustomWindowNewDemo extends AbstractPage  {

    private Label inbtn=new Label("   【入库】 0件");
    private Label usebtn=new Label("   【取货】 0件");
    private Label backbtn=new Label("  【还货】 0件");
    @Autowired
    private UseTabPage2 useTabPage;
    @Autowired
    private BackTabPage2 backTabPage;
    @Autowired
    private InboundTabPage2 inboundTabPage;
    List<AppPage> apps=new ArrayList<AppPage>();
    HBox hBbtns=null;
    int curbtns=0;
    Stage primaryStage;
    int isshow = 0;
    VBox center=null;
    public void start(Stage stage)  {
        if(isshow == 1) {
            isshow = 0;
            primaryStage.close();
        }

        primaryStage = new Stage();
        primaryStage.initOwner(stage);
        //primaryStage.initModality(Modality.APPLICATION_MODAL);
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        VBox root = new VBox();
        hBbtns=new HBox();
        hBbtns.getChildren().addAll(inbtn);
        hBbtns.setStyle("-fx-border-width: 0 1 1 1;-fx-border-style: solid;-fx-border-color: #5BA7AA;");
        hBbtns.setMinHeight(58);
        hBbtns.setMaxHeight(58);
        hBbtns.setMinWidth(1000);
        hBbtns.setMaxWidth(1000);
        inbtn.setStyle("-fx-background-color: #649fa3;-fx-background-radius: 0;-fx-text-alignment: center;-fx-text-fill: white");
        inbtn.setMinWidth(140);
        inbtn.setMinHeight(56);
        inbtn.setOnMouseClicked(e->{
            tablabe(0);
        });
        inbtn.setVisible(true);
        if(inboundTabPage.getInbonudItemLength()<=0){
          //  inbtn.setVisible(false);
          //  inbtn.setMaxWidth(0);
            hBbtns.getChildren().remove(inbtn);
        }else {
            inbtn.setText("   【入库】 "+inboundTabPage.getInbonudItemLength()+"件");
            apps.add(inboundTabPage);
        }
        hBbtns.getChildren().addAll(usebtn);
        usebtn.setStyle("-fx-text-fill: white;-fx-background-color: #649fa3;-fx-background-radius: 0;-fx-text-alignment: center");
        usebtn.setMinWidth(140);
        usebtn.setMinHeight(56);
        usebtn.setVisible(true);
        usebtn.setOnMouseClicked(e->{
            tablabe(1);

        });
        if(useTabPage.getInbonudItemLength()<=0){
            hBbtns.getChildren().remove(usebtn);
        }else {
            usebtn.setText("   【取货】 "+useTabPage.getInbonudItemLength()+"件");
            apps.add(useTabPage);
        }
        hBbtns.getChildren().addAll(backbtn);
        backbtn.setStyle("-fx-text-fill: white;-fx-background-color: #649fa3;-fx-background-radius: 0;-fx-text-alignment: center");
        backbtn.setMinWidth(140);
        backbtn.setMinHeight(56);
        backbtn.setOnMouseClicked(e->{
            tablabe(2);
        });
        backbtn.setVisible(true);
        if(backTabPage.getInbonudItemLength()<=0){
            hBbtns.getChildren().remove(backbtn);
        }
        else {
            usebtn.setText("   【还货】 "+backTabPage.getInbonudItemLength()+"件");
            apps.add(backTabPage);
        }
        Label lbczr=new Label("操作人: 陈道箐");
        lbczr.setTranslateX(460);
        lbczr.setTranslateY(-20);
        lbczr.setMinHeight(100);
        lbczr.setMaxHeight(100);
        lbczr.setMinWidth(100);
        lbczr.setMaxWidth(100);
        lbczr.setStyle("-fx-text-fill: black");
        center=new VBox();
       // center.setStyle("-fx-border-width: 1 1 1 1;-fx-border-style: solid;-fx-border-color: #5BA7AA;");
        center.setMinHeight(800);
        center.setMaxHeight(800);
        center.setMinWidth(550);
        center.setMaxWidth(550);
        center.setTranslateX(25);
        center.setTranslateY(-45);
        center.getChildren().add(inboundTabPage.tabInboundContent());
        Button closebtn=new Button("确认");
        closebtn.setStyle("-fx-background-color: white;-fx-border-color: #bababa;-fx-border-radius: 6");
        closebtn.setMinHeight(40);
        closebtn.setMaxHeight(40);
        closebtn.setMinWidth(160);
        closebtn.setMaxWidth(160);
        closebtn.setTranslateX(400);
        closebtn.setTranslateY(-30);
        closebtn.setOnMouseClicked(e->{
            primaryStage.close();
        });
        root.getChildren().addAll(hBbtns,lbczr,center,closebtn);
       // root.setStyle("");
        Scene scene = new Scene(root, 600, 1000);
        primaryStage.setScene(scene);
        primaryStage.setX(70);
        primaryStage.setY(120);
        root.setStyle("-fx-background-color: white;-fx-border-color: #bababa;-fx-border-insets: 1 1 1 1");
        tabfirst();

        //tablabe(0);
       if(isshow == 0) {
           isshow = 1;
            primaryStage.show();

        }
        primaryStage.setOnCloseRequest((WindowEvent event)->{
            //mainPage.refreturn();
        });
    }
    public void tablabe(int index){
        this.curbtns=index;
        for(int i=0;i<hBbtns.getChildren().size();i++){
            if(i!=index){
               // ((Label)hBbtns.getChildren().get(i)).setBackground((new Background(new BackgroundFill(Color.rgb(186, 186, 186), CornerRadii.EMPTY, Insets.EMPTY))));
                hBbtns.getChildren().get(i).setStyle("-fx-background-color: #bababa");

            }else {
                hBbtns.getChildren().get(i).setStyle("-fx-background-color: #649fa3");
                center.getChildren().clear();
                center.getChildren().add(apps.get(i).constructNode());
                //((Label)hBbtns.getChildren().get(i)).setBackground((new Background(new BackgroundFill(Color.rgb(100, 159, 163), CornerRadii.EMPTY, Insets.EMPTY))));
            }
            ((Label)hBbtns.getChildren().get(i)).setTextFill(Color.WHITE);
        }
    }
    public void tabfirst(){
        for(int i=0;i<hBbtns.getChildren().size();i++){
            if(hBbtns.getChildren().get(i).isVisible()){
                tablabe(i);
                return;
            }
        }
    }
    @Override
    protected Node constructNode() {
        return null;
    }

    @Override
    public void refresh() {

    }
}