添加form 表单 ,组件联动 2025年3月15日11:29:10
parent
6546b9c285
commit
e81095af0d
|
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import com.zhangmeng.online.exam.ui.api.form.UserForm;
|
||||||
import com.zhangmeng.online.exam.ui.api.model.PermissionDataLoad;
|
import com.zhangmeng.online.exam.ui.api.model.PermissionDataLoad;
|
||||||
import com.zhangmeng.online.exam.ui.api.model.QuestionDataLoad;
|
import com.zhangmeng.online.exam.ui.api.model.QuestionDataLoad;
|
||||||
import com.zhangmeng.online.exam.ui.api.model.RoleDataLoad;
|
import com.zhangmeng.online.exam.ui.api.model.RoleDataLoad;
|
||||||
|
|
@ -62,6 +63,7 @@ public class ApiUtils {
|
||||||
|
|
||||||
public static DataView getUserList() {
|
public static DataView getUserList() {
|
||||||
DataLoad dataLoad = new UserDataLoad();
|
DataLoad dataLoad = new UserDataLoad();
|
||||||
|
dataLoad.setForm(new UserForm());
|
||||||
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.zhangmeng.online.exam.ui.api;
|
package com.zhangmeng.online.exam.ui.api;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -13,4 +14,11 @@ import java.util.Map;
|
||||||
public interface DataLoad {
|
public interface DataLoad {
|
||||||
|
|
||||||
public ApiUtils.DataView loadData(Integer pageNum, Integer pageSize);
|
public ApiUtils.DataView loadData(Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
public void setForm(Parent view);
|
||||||
|
|
||||||
|
public Parent getForm();
|
||||||
|
|
||||||
|
Map<String, Object> saveForm(Map<String, Object> map);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.zhangmeng.online.exam.ui.api.form;
|
||||||
|
|
||||||
|
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
|
import com.zhangmeng.online.exam.ui.api.model.UserDataLoad;
|
||||||
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
|
import com.zhangmeng.online.exam.ui.components.callBack.DynamicTableComponentCallBack;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.PasswordField;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.Window;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zm
|
||||||
|
* @date 2025/3/14 17:40
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
public class UserForm extends AnchorPane {
|
||||||
|
|
||||||
|
private DynamicTableComponent tableComponent;
|
||||||
|
|
||||||
|
public DynamicTableComponent getTableComponent() {
|
||||||
|
return tableComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTableComponent(DynamicTableComponent tableComponent) {
|
||||||
|
this.tableComponent = tableComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserForm() {
|
||||||
|
|
||||||
|
Label username_label = new Label("用户名:");
|
||||||
|
username_label.setLayoutX(83.0);
|
||||||
|
username_label.setLayoutY(64.0);
|
||||||
|
|
||||||
|
TextField username_field = new TextField();
|
||||||
|
username_field.setLayoutX(162.0);
|
||||||
|
username_field.setLayoutY(60.0);
|
||||||
|
username_field.setPrefHeight(23.0);
|
||||||
|
username_field.setPrefWidth(289.0);
|
||||||
|
username_field.setPromptText("请输入用户名");
|
||||||
|
|
||||||
|
PasswordField password_field = new PasswordField();
|
||||||
|
password_field.setLayoutX(162.0);
|
||||||
|
password_field.setLayoutY(117.0);
|
||||||
|
password_field.setPrefHeight(23.0);
|
||||||
|
password_field.setPrefWidth(289.0);
|
||||||
|
password_field.setPromptText("请输入密码");
|
||||||
|
|
||||||
|
Label password_label = new Label("密码:");
|
||||||
|
password_label.setLayoutX(87.0);
|
||||||
|
password_label.setLayoutY(121.0);
|
||||||
|
|
||||||
|
Label phone_label = new Label("手机号:");
|
||||||
|
phone_label.setLayoutX(87.0);
|
||||||
|
phone_label.setLayoutY(169.0);
|
||||||
|
|
||||||
|
TextField phone_field = new TextField();
|
||||||
|
phone_field.setLayoutX(162.0);
|
||||||
|
phone_field.setLayoutY(165.0);
|
||||||
|
phone_field.setPrefHeight(23.0);
|
||||||
|
phone_field.setPrefWidth(289.0);
|
||||||
|
phone_field.setPromptText("请输入手机号");
|
||||||
|
|
||||||
|
Label email_label = new Label("邮箱:");
|
||||||
|
email_label.setLayoutX(87.0);
|
||||||
|
email_label.setLayoutY(224.0);
|
||||||
|
|
||||||
|
TextField email_field = new TextField();
|
||||||
|
email_field.setLayoutX(162.0);
|
||||||
|
email_field.setLayoutY(220.0);
|
||||||
|
email_field.setPrefHeight(23.0);
|
||||||
|
email_field.setPrefWidth(289.0);
|
||||||
|
email_field.setPromptText("请输入邮箱");
|
||||||
|
|
||||||
|
Button submit_button = new Button("提交");
|
||||||
|
submit_button.setLayoutX(263.0);
|
||||||
|
submit_button.setLayoutY(288.0);
|
||||||
|
|
||||||
|
submit_button.setOnAction(e -> {
|
||||||
|
|
||||||
|
DataLoad formDataLoad = new UserDataLoad();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("username", username_field.getText());
|
||||||
|
map.put("password", password_field.getText());
|
||||||
|
map.put("phone", phone_field.getText());
|
||||||
|
map.put("email", email_field.getText());
|
||||||
|
formDataLoad.saveForm(map);
|
||||||
|
|
||||||
|
Stage stage = (Stage) this.getScene().getWindow();
|
||||||
|
stage.close();
|
||||||
|
|
||||||
|
DynamicTableComponentCallBack callBack = tableComponent.getCallBack();
|
||||||
|
ObservableList<Map<String, SimpleStringProperty>> data = tableComponent.getData();
|
||||||
|
data.clear();
|
||||||
|
data.addAll(callBack.flushData(1, ApiUtils.PAGE_SIZE).getDataList());
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
this.getChildren().addAll(username_label,
|
||||||
|
username_field,
|
||||||
|
password_field,
|
||||||
|
phone_label,
|
||||||
|
phone_field,
|
||||||
|
email_label,
|
||||||
|
email_field,
|
||||||
|
submit_button,
|
||||||
|
password_label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
@ -40,4 +41,19 @@ public class PermissionDataLoad implements DataLoad {
|
||||||
}
|
}
|
||||||
return new ApiUtils.DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), permissionMapList).setDataLoad(this).setPageNum(pageNum).setPageSize(pageSize).setTotal(total);
|
return new ApiUtils.DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), permissionMapList).setDataLoad(this).setPageNum(pageNum).setPageSize(pageSize).setTotal(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setForm(Parent view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parent getForm() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> saveForm(Map<String, Object> map) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
@ -40,4 +41,20 @@ public class QuestionDataLoad implements DataLoad {
|
||||||
}
|
}
|
||||||
return new ApiUtils.DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), questionMapList).setDataLoad(this).setPageNum(pageNum).setPageSize(pageSize).setTotal(total);
|
return new ApiUtils.DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), questionMapList).setDataLoad(this).setPageNum(pageNum).setPageSize(pageSize).setTotal(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setForm(Parent view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parent getForm() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> saveForm(Map<String, Object> map) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
@ -40,4 +41,19 @@ public class RoleDataLoad implements DataLoad {
|
||||||
}
|
}
|
||||||
return new ApiUtils.DataView(Arrays.asList("序号", "角色名称", "描述", "角色类型"), roleMapList).setDataLoad(this).setPageNum(pageNum).setPageSize(pageSize).setTotal(total);
|
return new ApiUtils.DataView(Arrays.asList("序号", "角色名称", "描述", "角色类型"), roleMapList).setDataLoad(this).setPageNum(pageNum).setPageSize(pageSize).setTotal(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setForm(Parent view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parent getForm() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> saveForm(Map<String, Object> map) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
|
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
|
||||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zm
|
* @author zm
|
||||||
|
|
@ -17,6 +19,9 @@ import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
* @version: 1.0
|
* @version: 1.0
|
||||||
*/
|
*/
|
||||||
public class UserDataLoad implements DataLoad {
|
public class UserDataLoad implements DataLoad {
|
||||||
|
|
||||||
|
private Parent form;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiUtils.DataView loadData(Integer pageNum, Integer pageSize) {
|
public ApiUtils.DataView loadData(Integer pageNum, Integer pageSize) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
|
@ -41,4 +46,26 @@ public class UserDataLoad implements DataLoad {
|
||||||
dataView.setDataLoad(this);
|
dataView.setDataLoad(this);
|
||||||
return dataView;
|
return dataView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setForm(Parent view) {
|
||||||
|
this.form = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parent getForm() {
|
||||||
|
return this.form;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> saveForm(Map<String, Object> map) {
|
||||||
|
String result = HttpUtils.POST(ApiUtils.API_URL + "/user/save", map);
|
||||||
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
if (jsonObject.getIntValue("code") == 200){
|
||||||
|
AlertUtils.alert_msg("保存成功!");
|
||||||
|
}else {
|
||||||
|
AlertUtils.alert_warning("保存失败!");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Pagination;
|
import javafx.scene.control.Pagination;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
|
|
@ -16,6 +17,8 @@ import javafx.scene.control.cell.MapValueFactory;
|
||||||
import javafx.scene.control.cell.TextFieldTableCell;
|
import javafx.scene.control.cell.TextFieldTableCell;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.Window;
|
||||||
import org.casic.javafx.control.PaginationPicker;
|
import org.casic.javafx.control.PaginationPicker;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -44,6 +47,10 @@ public class DynamicTableComponent extends VBox {
|
||||||
|
|
||||||
private final ObservableList<Map<String, SimpleStringProperty>> data = FXCollections.observableArrayList();
|
private final ObservableList<Map<String, SimpleStringProperty>> data = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
public ObservableList<Map<String, SimpleStringProperty>> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
// public DynamicTableComponent(List<Map<String, SimpleStringProperty>> dataList,List<String> keys) {
|
// public DynamicTableComponent(List<Map<String, SimpleStringProperty>> dataList,List<String> keys) {
|
||||||
public DynamicTableComponent(ApiUtils.DataView dataView) {
|
public DynamicTableComponent(ApiUtils.DataView dataView) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -77,6 +84,15 @@ public class DynamicTableComponent extends VBox {
|
||||||
tableView.getColumns().add(column);
|
tableView.getColumns().add(column);
|
||||||
});
|
});
|
||||||
data.addAll(dataList);
|
data.addAll(dataList);
|
||||||
|
|
||||||
|
///添加按钮
|
||||||
|
Button button = new Button("新增");
|
||||||
|
button.setOnAction(event -> {
|
||||||
|
Stage window = (Stage) this.getScene().getWindow();
|
||||||
|
callBack.Add(callBack.getAddForm(), window,this);
|
||||||
|
});
|
||||||
|
this.getChildren().add(button);
|
||||||
|
this.setSpacing(10);
|
||||||
this.getChildren().addAll(tableView);
|
this.getChildren().addAll(tableView);
|
||||||
|
|
||||||
//初始化一个分页
|
//初始化一个分页
|
||||||
|
|
@ -95,7 +111,6 @@ public class DynamicTableComponent extends VBox {
|
||||||
data.addAll(callBack.flushData(paginationPicker.getCurrentPage(),paginationPicker.getPageSize()).getDataList());
|
data.addAll(callBack.flushData(paginationPicker.getCurrentPage(),paginationPicker.getPageSize()).getDataList());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getChildren().add(paginationPicker);
|
this.getChildren().add(paginationPicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,11 @@ package com.zhangmeng.online.exam.ui.components.callBack;
|
||||||
|
|
||||||
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -16,4 +20,8 @@ public interface DynamicTableComponentCallBack {
|
||||||
|
|
||||||
public ApiUtils.DataView flushData(Integer pageNum, Integer pageSize);
|
public ApiUtils.DataView flushData(Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
//新增数据
|
||||||
|
public void Add(Parent node, Stage primaryStage, DynamicTableComponent dynamicTableComponent);
|
||||||
|
|
||||||
|
public Parent getAddForm();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,14 @@ package com.zhangmeng.online.exam.ui.components.callBack;
|
||||||
|
|
||||||
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
|
import com.zhangmeng.online.exam.ui.api.form.UserForm;
|
||||||
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
|
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -16,6 +23,13 @@ public class DynamicTableComponentCallBackImpl implements DynamicTableComponentC
|
||||||
|
|
||||||
private DataLoad dataLoad;
|
private DataLoad dataLoad;
|
||||||
|
|
||||||
|
private Parent node;
|
||||||
|
|
||||||
|
public DynamicTableComponentCallBackImpl(DataLoad dataLoad,Parent node) {
|
||||||
|
this.dataLoad = dataLoad;
|
||||||
|
this.node = node;
|
||||||
|
}
|
||||||
|
|
||||||
public DynamicTableComponentCallBackImpl(DataLoad dataLoad) {
|
public DynamicTableComponentCallBackImpl(DataLoad dataLoad) {
|
||||||
this.dataLoad = dataLoad;
|
this.dataLoad = dataLoad;
|
||||||
}
|
}
|
||||||
|
|
@ -25,6 +39,18 @@ public class DynamicTableComponentCallBackImpl implements DynamicTableComponentC
|
||||||
return dataLoad.loadData(pageNum, pageSize);
|
return dataLoad.loadData(pageNum, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Add(Parent node, Stage primaryStage, DynamicTableComponent table) {
|
||||||
|
UserForm userForm = (UserForm)node;
|
||||||
|
userForm.setTableComponent(table);
|
||||||
|
AlertUtils.alert("设置", node, primaryStage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parent getAddForm() {
|
||||||
|
return this.node;
|
||||||
|
}
|
||||||
|
|
||||||
public DataLoad getDataLoad() {
|
public DataLoad getDataLoad() {
|
||||||
return dataLoad;
|
return dataLoad;
|
||||||
}
|
}
|
||||||
|
|
@ -32,4 +58,12 @@ public class DynamicTableComponentCallBackImpl implements DynamicTableComponentC
|
||||||
public void setDataLoad(DataLoad dataLoad) {
|
public void setDataLoad(DataLoad dataLoad) {
|
||||||
this.dataLoad = dataLoad;
|
this.dataLoad = dataLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Node getNode() {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNode(Parent node) {
|
||||||
|
this.node = node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ public class SideMenu extends VBox {
|
||||||
tp.expandedProperty().addListener(new ChangeListener<Boolean>() {
|
tp.expandedProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||||
System.out.println("tp.expandedProperty().addListener====>" + newValue);
|
//System.out.println("tp.expandedProperty().addListener====>" + newValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -151,10 +151,10 @@ public class SideMenu extends VBox {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends TitledPane> observable, TitledPane oldValue, TitledPane newValue) {
|
public void changed(ObservableValue<? extends TitledPane> observable, TitledPane oldValue, TitledPane newValue) {
|
||||||
if (newValue == null) {
|
if (newValue == null) {
|
||||||
System.out.println(oldValue.getText() + "=====>折叠");
|
//System.out.println(oldValue.getText() + "=====>折叠");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println(newValue.getText() + "=====>展开");
|
//System.out.println(newValue.getText() + "=====>展开");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ public class SideMenu extends VBox {
|
||||||
dataView.setPageSize(dataView.getPageSize());
|
dataView.setPageSize(dataView.getPageSize());
|
||||||
dataView.setTotal(dataView.getTotal());
|
dataView.setTotal(dataView.getTotal());
|
||||||
DynamicTableComponent dynamicTableComponent = new DynamicTableComponent(dataView);
|
DynamicTableComponent dynamicTableComponent = new DynamicTableComponent(dataView);
|
||||||
dynamicTableComponent.setCallBack(new DynamicTableComponentCallBackImpl(dataView.getDataLoad()));
|
dynamicTableComponent.setCallBack(new DynamicTableComponentCallBackImpl(dataView.getDataLoad(),dataView.getDataLoad().getForm()));
|
||||||
dynamicTableComponent.setPadding(new Insets(15));
|
dynamicTableComponent.setPadding(new Insets(15));
|
||||||
dynamicTableComponent.prefHeightProperty().bind(root.heightProperty().subtract(15));
|
dynamicTableComponent.prefHeightProperty().bind(root.heightProperty().subtract(15));
|
||||||
root.setCenter(dynamicTableComponent);
|
root.setCenter(dynamicTableComponent);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 芊芊墨客
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.zhangmeng.online.exam.ui.utils;
|
||||||
|
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Group;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.stage.Modality;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.StageStyle;
|
||||||
|
import javafx.stage.Window;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 芊芊墨客
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2023-02-17 09:59
|
||||||
|
*/
|
||||||
|
public class AlertUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 警告弹窗
|
||||||
|
*/
|
||||||
|
public static void alert_warning(String msg) {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||||
|
alert.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
alert.setContentText(msg);
|
||||||
|
alert.setHeaderText(null);
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void alert_msg(String msg) {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
|
alert.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
alert.setContentText(msg);
|
||||||
|
alert.setHeaderText(null);
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void alert(String title, Parent node, Stage primaryStage) {
|
||||||
|
alert(title, node, 600, 400, primaryStage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void alert(String title, Parent node, int width, int height, Stage primaryStage) {
|
||||||
|
|
||||||
|
Scene scene = new Scene(new Group(node));
|
||||||
|
Stage stage = new Stage();
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle(title);
|
||||||
|
stage.setWidth(width);
|
||||||
|
stage.setHeight(height);
|
||||||
|
stage.initStyle(StageStyle.UTILITY);
|
||||||
|
stage.initOwner(primaryStage);
|
||||||
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
stage.setResizable(false);
|
||||||
|
stage.show();
|
||||||
|
stage.setOnCloseRequest(e -> {
|
||||||
|
stage.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -32,9 +32,8 @@ public class HttpUtils<T> {
|
||||||
return HttpUtil.get(url, params);
|
return HttpUtil.get(url, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T POST(String url, Map<String, Object> params, Class<T> clazz) {
|
public static String POST(String url, Map<String, Object> params) {
|
||||||
String response = HttpUtil.post(url, params);
|
return HttpUtil.post(url, params);
|
||||||
return JSONObject.parseObject(response, clazz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T POSTFileUPLOAD(String url, Map<String, Object> params, File file, Class<T> clazz) {
|
public static <T> T POSTFileUPLOAD(String url, Map<String, Object> params, File file, Class<T> clazz) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.PasswordField?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fmxl.UserForm">
|
||||||
|
<children>
|
||||||
|
<Label layoutX="83.0" layoutY="64.0" text="用户名:" />
|
||||||
|
<PasswordField layoutX="162.0" layoutY="117.0" prefHeight="23.0" prefWidth="289.0" />
|
||||||
|
<Label layoutX="87.0" layoutY="121.0" text="密码:" />
|
||||||
|
<Label layoutX="87.0" layoutY="169.0" text="手机号:" />
|
||||||
|
<Label layoutX="87.0" layoutY="224.0" text="邮箱:" />
|
||||||
|
<TextField layoutX="162.0" layoutY="60.0" prefHeight="23.0" prefWidth="289.0" />
|
||||||
|
<TextField layoutX="162.0" layoutY="165.0" prefHeight="23.0" prefWidth="289.0" />
|
||||||
|
<TextField layoutX="162.0" layoutY="220.0" prefHeight="23.0" prefWidth="289.0" />
|
||||||
|
<Button layoutX="263.0" layoutY="288.0" mnemonicParsing="false" text="提交" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
Loading…
Reference in New Issue