添加删除功能 2025年3月15日11:59:52
parent
e81095af0d
commit
2152c77ba2
|
|
@ -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.RoleForm;
|
||||||
import com.zhangmeng.online.exam.ui.api.form.UserForm;
|
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;
|
||||||
|
|
@ -69,6 +70,7 @@ public class ApiUtils {
|
||||||
|
|
||||||
public static DataView getRoleList() {
|
public static DataView getRoleList() {
|
||||||
DataLoad dataLoad = new RoleDataLoad();
|
DataLoad dataLoad = new RoleDataLoad();
|
||||||
|
dataLoad.setForm(new RoleForm());
|
||||||
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,5 @@ public interface DataLoad {
|
||||||
|
|
||||||
Map<String, Object> saveForm(Map<String, Object> map);
|
Map<String, Object> saveForm(Map<String, Object> map);
|
||||||
|
|
||||||
|
public void deleteData(String id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
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.form.base.Form;
|
||||||
|
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.*;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zm
|
||||||
|
* @date 2025/3/15 11:38
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
public class RoleForm extends Form {
|
||||||
|
|
||||||
|
public RoleForm() {
|
||||||
|
Label label1 = new Label("类型:");
|
||||||
|
label1.setLayoutX(135.0);
|
||||||
|
label1.setLayoutY(84.0);
|
||||||
|
Label label2 = new Label("角色名称:");
|
||||||
|
label2.setLayoutX(130.0);
|
||||||
|
label2.setLayoutY(145.0);
|
||||||
|
Label label3 = new Label("角色描述:");
|
||||||
|
label3.setLayoutX(123.0);
|
||||||
|
label3.setLayoutY(209.0);
|
||||||
|
|
||||||
|
ChoiceBox choiceBox = new ChoiceBox();
|
||||||
|
choiceBox.setLayoutX(200);
|
||||||
|
choiceBox.setLayoutY(80.0);
|
||||||
|
choiceBox.setPrefHeight(23.0);
|
||||||
|
choiceBox.setPrefWidth(229.0);
|
||||||
|
choiceBox.getItems().addAll("管理员", "教师", "学生");
|
||||||
|
choiceBox.setTooltip(new Tooltip("请选择类型"));
|
||||||
|
|
||||||
|
TextField textField1 = new TextField();
|
||||||
|
textField1.setLayoutX(200.0);
|
||||||
|
textField1.setLayoutY(141.0);
|
||||||
|
textField1.setPrefHeight(23.0);
|
||||||
|
textField1.setPrefWidth(229.0);
|
||||||
|
|
||||||
|
TextField textField2 = new TextField();
|
||||||
|
textField2.setLayoutX(200);
|
||||||
|
textField2.setLayoutY(205.0);
|
||||||
|
textField2.setPrefHeight(23.0);
|
||||||
|
textField2.setPrefWidth(229.0);
|
||||||
|
|
||||||
|
Button button1 = new Button("保存");
|
||||||
|
button1.setLayoutX(267.0);
|
||||||
|
button1.setLayoutY(289.0);
|
||||||
|
button1.setMnemonicParsing(false);
|
||||||
|
button1.setText("保存");
|
||||||
|
|
||||||
|
this.getChildren().addAll(label1, label2, label3, choiceBox, textField1, textField2, button1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.zhangmeng.online.exam.ui.api.form;
|
||||||
|
|
||||||
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.base.Form;
|
||||||
import com.zhangmeng.online.exam.ui.api.model.UserDataLoad;
|
import com.zhangmeng.online.exam.ui.api.model.UserDataLoad;
|
||||||
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
import com.zhangmeng.online.exam.ui.components.callBack.DynamicTableComponentCallBack;
|
import com.zhangmeng.online.exam.ui.components.callBack.DynamicTableComponentCallBack;
|
||||||
|
|
@ -23,17 +24,7 @@ import java.util.Map;
|
||||||
* @date 2025/3/14 17:40
|
* @date 2025/3/14 17:40
|
||||||
* @version: 1.0
|
* @version: 1.0
|
||||||
*/
|
*/
|
||||||
public class UserForm extends AnchorPane {
|
public class UserForm extends Form {
|
||||||
|
|
||||||
private DynamicTableComponent tableComponent;
|
|
||||||
|
|
||||||
public DynamicTableComponent getTableComponent() {
|
|
||||||
return tableComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableComponent(DynamicTableComponent tableComponent) {
|
|
||||||
this.tableComponent = tableComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserForm() {
|
public UserForm() {
|
||||||
|
|
||||||
|
|
@ -98,8 +89,8 @@ public class UserForm extends AnchorPane {
|
||||||
Stage stage = (Stage) this.getScene().getWindow();
|
Stage stage = (Stage) this.getScene().getWindow();
|
||||||
stage.close();
|
stage.close();
|
||||||
|
|
||||||
DynamicTableComponentCallBack callBack = tableComponent.getCallBack();
|
DynamicTableComponentCallBack callBack = getTableComponent().getCallBack();
|
||||||
ObservableList<Map<String, SimpleStringProperty>> data = tableComponent.getData();
|
ObservableList<Map<String, SimpleStringProperty>> data = getTableComponent().getData();
|
||||||
data.clear();
|
data.clear();
|
||||||
data.addAll(callBack.flushData(1, ApiUtils.PAGE_SIZE).getDataList());
|
data.addAll(callBack.flushData(1, ApiUtils.PAGE_SIZE).getDataList());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.zhangmeng.online.exam.ui.api.form.base;
|
||||||
|
|
||||||
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zm
|
||||||
|
* @date 2025/3/15 11:46
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
public class Form extends AnchorPane {
|
||||||
|
|
||||||
|
private DynamicTableComponent tableComponent;
|
||||||
|
|
||||||
|
public DynamicTableComponent getTableComponent() {
|
||||||
|
return tableComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTableComponent(DynamicTableComponent tableComponent) {
|
||||||
|
this.tableComponent = tableComponent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -56,4 +56,9 @@ public class PermissionDataLoad implements DataLoad {
|
||||||
public Map<String, Object> saveForm(Map<String, Object> map) {
|
public Map<String, Object> saveForm(Map<String, Object> map) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteData(String id) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,11 @@ public class QuestionDataLoad implements DataLoad {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteData(String id) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> saveForm(Map<String, Object> map) {
|
public Map<String, Object> saveForm(Map<String, Object> map) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ import static com.zhangmeng.online.exam.ui.api.ApiUtils.API_URL;
|
||||||
* @version: 1.0
|
* @version: 1.0
|
||||||
*/
|
*/
|
||||||
public class RoleDataLoad implements DataLoad {
|
public class RoleDataLoad 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<>();
|
||||||
|
|
@ -44,16 +46,21 @@ public class RoleDataLoad implements DataLoad {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setForm(Parent view) {
|
public void setForm(Parent view) {
|
||||||
|
this.form = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Parent getForm() {
|
public Parent getForm() {
|
||||||
return null;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> saveForm(Map<String, Object> map) {
|
public Map<String, Object> saveForm(Map<String, Object> map) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteData(String id) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,4 +68,9 @@ public class UserDataLoad implements DataLoad {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteData(String id) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ 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.api.form.UserForm;
|
||||||
|
import com.zhangmeng.online.exam.ui.api.form.base.Form;
|
||||||
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
|
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
@ -41,8 +42,8 @@ public class DynamicTableComponentCallBackImpl implements DynamicTableComponentC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Add(Parent node, Stage primaryStage, DynamicTableComponent table) {
|
public void Add(Parent node, Stage primaryStage, DynamicTableComponent table) {
|
||||||
UserForm userForm = (UserForm)node;
|
Form form = (Form) node;
|
||||||
userForm.setTableComponent(table);
|
form.setTableComponent(table);
|
||||||
AlertUtils.alert("设置", node, primaryStage);
|
AlertUtils.alert("设置", node, primaryStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ChoiceBox?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?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.RoleForm">
|
||||||
|
<children>
|
||||||
|
<Label layoutX="135.0" layoutY="84.0" text="类型:" />
|
||||||
|
<Label layoutX="130.0" layoutY="145.0" text="角色名称:" />
|
||||||
|
<Label layoutX="123.0" layoutY="209.0" text="角色描述:" />
|
||||||
|
<ChoiceBox layoutX="234.0" layoutY="80.0" prefHeight="23.0" prefWidth="229.0" />
|
||||||
|
<TextField layoutX="234.0" layoutY="141.0" prefHeight="23.0" prefWidth="229.0" />
|
||||||
|
<TextField layoutX="234.0" layoutY="205.0" prefHeight="23.0" prefWidth="229.0" />
|
||||||
|
<Button layoutX="267.0" layoutY="289.0" mnemonicParsing="false" text="保存" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
Loading…
Reference in New Issue