AppPage.java
5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package cn.csbr.app.gui.page;
import cn.csbr.app.gui.page.useAndBackTab.BackTabPage;
import cn.csbr.app.gui.page.useAndBackTab.UseTabPage;
import cn.csbr.app.model.InboundItem;
import cn.csbr.app.service.TabUseBackService;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;
import cn.csbr.app.config.FxConfigure;
import cn.csbr.app.gui.GUIContext;
import cn.csbr.app.gui.component.common.ImageButton;
import cn.hutool.core.date.DateUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 出库入库这些都是要集成子这个类的 这个类里边做基本的布局管理
*/
public abstract class AppPage extends AbstractPage {
Label userlable = new Label();
Label timelable = new Label();
Label label = new Label();
//控制时间的变化
private boolean timeflag = false;
@Autowired
private GUIContext context;
public HBox head=null;
@Autowired
private FxConfigure fxConfigure;
/**
* 第一排是用户名和密码 第二排是文字的名称 第三批是按钮 第四排是公司名称版本号
*
* @return
*/
private Node createHeader() {
HBox headerBox = new HBox();
// Region spacer = new Region();
// spacer.setMinWidth(550);
// titlelabel.setId("appTitle");
// titlelabel.setText(getTitle());
// titlelabel.setMinWidth(250);
// namelabel.setId("namelabel");
// namelabel.setWrapText(false);
// namelabel.setMinWidth(180);
// timelabel.setId("timelabel");
// timelabel.setWrapText(false);
// timelabel.setMinWidth(150);
// label =new Label(getTitle());
label.setText(getTitle());
label.setFont(Font.font("圆体",28));
label.setTranslateX(950);
label.setTranslateY(-290);
label.setTextFill(Color.WHITE);
// userlable=new Label("张三 / 内科2区");
userlable.setFont(Font.font("14"));
userlable.setTextFill(Color.rgb(140,140,140));
userlable.setTranslateX(260);
userlable.setTranslateY(-220);
VBox imagehb1=new VBox();
imagehb1.setStyle("-fx-background-image: url(images/New/renyuan.png);-fx-background-repeat: stretch;-fx-background-position: center center;");
imagehb1.setTranslateX(255);
imagehb1.setTranslateY(-212);
imagehb1.setMinWidth(30);
//imagehb1.setStyle("-fx-background-color: red");
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd hh:mm:ss" );
// String str = sdf.format(new Date());
//timelable=new Label(sdf.format(new Date()));
timelable.setFont(Font.font("14"));
timelable.setTextFill(Color.rgb(140,140,140));
timelable.setTranslateX(360);
timelable.setTranslateY(-220);
HBox imagehb2=new HBox();
imagehb2.setTranslateX(355);
imagehb2.setTranslateY(-212);
imagehb2.setMinWidth(30);
imagehb2.setStyle("-fx-background-image: url(images/New/24hour.png);-fx-background-repeat: stretch;-fx-background-position: center center;");
headerBox.getChildren().addAll(label,imagehb1,userlable,imagehb2,timelable);
headerBox.setMinWidth(fxConfigure.getMinWidth());
headerBox.setStyle("-fx-text-alignment:left;-fx-alignment:bottom-left");
head=headerBox;
return headerBox;
}
@Override
protected Node constructNode() {
this.setTitle(appTitle());
VBox main = new VBox();
main.setId("appPage");
// main.getStylesheets().add("styles/app.css");
main.setPadding(new Insets(10, 10, 10, 10));
Region spacer = new Region();
spacer.setMinHeight(50);
Node node =appContent();
if (node!= null) {
main.getChildren().addAll(createHeader(), spacer, node);
} else {
main.getChildren().add(createHeader());
}
main.setMinWidth(fxConfigure.getMinWidth());
main.setMinHeight(fxConfigure.getMinHeight());
main.setMaxHeight(fxConfigure.getMinHeight());
main.setMaxWidth(fxConfigure.getMinWidth());
return main;
}
@Override
public void refresh() {
StringBuilder desc = new StringBuilder();
desc.append(context.getLoginUser().getUserName() + "/" + context.getLoginUser().getOrgName());
userlable.setText(desc.toString());
timelable.setText(DateUtil.now());
if(!timeflag) {
new Thread(() -> {
try {
timeflag = true;
while (timeflag) {
Platform.runLater(() -> {
timelable.setText(DateUtil.now());
});
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
appRefresh();
}
abstract protected void appRefresh();
abstract protected Node appContent();
abstract protected String appTitle();
}