Compare commits
22 Commits
master
...
dev_featur
| Author | SHA1 | Date |
|---|---|---|
|
|
5c10cdd849 | 2 weeks ago |
|
|
0b0c13ab20 | 2 weeks ago |
|
|
32ab919eef | 2 weeks ago |
|
|
5c569c2fb4 | 3 weeks ago |
|
|
3700a1e821 | 2 months ago |
|
|
8ea96c7116 | 2 months ago |
|
|
7935d60668 | 2 months ago |
|
|
829196f7f4 | 2 months ago |
|
|
a2a02a35f5 | 2 months ago |
|
|
5ddf2b6b46 | 2 months ago |
|
|
63fb628033 | 2 months ago |
|
|
a3664d011b | 2 months ago |
|
|
465703d38b | 2 months ago |
|
|
4636ddd78a | 2 months ago |
|
|
7ee8fa9597 | 2 months ago |
|
|
810152443b | 2 months ago |
|
|
c975221ea9 | 3 months ago |
|
|
7b87d80120 | 3 months ago |
|
|
e5b7b698a9 | 3 months ago |
|
|
61164e395b | 3 months ago |
|
|
fd8ff44d15 | 3 months ago |
|
|
b26509b119 | 3 months ago |
15 changed files with 1055 additions and 16 deletions
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
package apelet.tenantadmin.tenant.plugin; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.core.object.TokenData; |
||||
import apelet.common.core.util.ApplicationContextHolder; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/* |
||||
报价单插件 |
||||
*/ |
||||
public class QuotationPlugin extends ExecutePluginParent { |
||||
private static final OrmGenDataSourceUtil ORM_GEN_DATA_SOURCE_UTIL = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); |
||||
@Override |
||||
public void formCreated(String widgetVariableName, ObjectValue objectValue){ |
||||
super.formCreated(widgetVariableName, objectValue); |
||||
//获取当前登录的用户ID
|
||||
TokenData tokenData = TokenData.takeFromRequest(); |
||||
Long userId = tokenData.getUserId(); |
||||
//查询当前用户信息
|
||||
ObjectValue sysUserInfo = ORM_GEN_DATA_SOURCE_UTIL.queryOne("xy_sys_user", userId); |
||||
//赋值
|
||||
if (sysUserInfo != null){ |
||||
this.setWidgetAttribute("managerperson", AttributeEnum.VALUE_CHANGE, sysUserInfo); |
||||
} |
||||
|
||||
//隐藏拒绝理由
|
||||
this.setWidgetAttribute("canaelreason",AttributeEnum.SHOW,false); |
||||
//设置报价单状态
|
||||
this.setWidgetAttribute("status",AttributeEnum.VALUE_CHANGE,"1"); |
||||
//设置总价初始值为0
|
||||
this.setWidgetAttribute("qty",AttributeEnum.VALUE_CHANGE,0); |
||||
} |
||||
|
||||
@Override |
||||
public void change(String widgetVariableName, ObjectValue objectValue){ |
||||
super.change(widgetVariableName, objectValue); |
||||
//获取报价单状态
|
||||
String status = objectValue.getString("status"); |
||||
//若status为"4"
|
||||
if(status.equals("4")){ |
||||
this.setWidgetAttribute("canaelreason",AttributeEnum.SHOW,true); |
||||
}else { |
||||
this.setWidgetAttribute("canaelreason",AttributeEnum.SHOW,false); |
||||
} |
||||
|
||||
//获取单据体
|
||||
ObjectCollection quotationE = objectValue.getObjectCollection("quotation_e"); |
||||
// 总金额
|
||||
BigDecimal allTotalAmount = BigDecimal.ZERO; |
||||
//判断是否有数据
|
||||
if (quotationE != null && !quotationE.isEmpty()){ |
||||
for (int i = 0; i < quotationE.size(); i++ ){ |
||||
// 获取行数据
|
||||
ObjectValue row = quotationE.getObject(i); |
||||
//获取指导折扣价
|
||||
BigDecimal discount = row.getBigDecimal("discount"); |
||||
// 判空处理
|
||||
if (discount == null) { |
||||
discount = BigDecimal.ZERO; |
||||
} |
||||
//获取数量
|
||||
int num = row.getInt("num"); |
||||
|
||||
// 计算总价 = 折扣价 * 数量
|
||||
BigDecimal totalAmount = discount.multiply(BigDecimal.valueOf(num)); |
||||
allTotalAmount = allTotalAmount.add(totalAmount); |
||||
} |
||||
this.setWidgetAttribute("qty",AttributeEnum.VALUE_CHANGE,allTotalAmount); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
package apelet.tenantadmin.tenant.plugin; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.plugin.BeforeExecuteOperationArgs; |
||||
import apelet.common.online.plugin.OperationServicePlugIn; |
||||
|
||||
//提交后修改状态
|
||||
public class StatusChangePlugin extends OperationServicePlugIn { |
||||
@Override |
||||
public void beforeExecuteOperationTransaction(BeforeExecuteOperationArgs e){ |
||||
super.beforeExecuteOperationTransaction(e); |
||||
ObjectCollection modelCollcetion = e.getModelCollcetion(); |
||||
|
||||
if(modelCollcetion != null && !modelCollcetion.isEmpty()){ |
||||
for (int i = 0; i < modelCollcetion.size(); i++) { |
||||
// 获取单据对象
|
||||
ObjectValue bill = modelCollcetion.getObject(i); |
||||
bill.setString("status","2"); |
||||
//保存入库
|
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package apelet.association.controller.plugin.formPlugin; |
||||
|
||||
import apelet.association.utils.CreatNumberUtils; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
public class ClueManageFormPlugin extends ExecutePluginParent { |
||||
@Override |
||||
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||
super.formCreated(widgetVariableName, objectValue); |
||||
// this.setAttribute("seekInfo","11");
|
||||
// this.setWidgetAttribute("number", AttributeEnum.VALUE_CHANGE, "123");
|
||||
CreatNumberUtils creatNumberUtils = new CreatNumberUtils(); |
||||
this.setWidgetAttribute("billstatus", AttributeEnum.VALUE_CHANGE,"1"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.online.abstractplugin.ListPlugin; |
||||
import apelet.common.online.dto.OnlineEventPluginExecuteDto; |
||||
import apelet.common.orm.impl.Filter; |
||||
import apelet.common.orm.impl.FilterItem; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 入会申请历史列表过滤插件。 |
||||
*/ |
||||
public class MembershipApplyHistoryListFilterPlugin extends ListPlugin { |
||||
|
||||
private static final String PARAM_BILL_NUMBER = "billNumber"; |
||||
|
||||
private static final String FIELD_NUMBER = "number"; |
||||
|
||||
@Override |
||||
protected Filter getFilter() { |
||||
Filter filter = new Filter(); |
||||
OnlineEventPluginExecuteDto dto = getDto(); |
||||
if (dto == null || dto.getEventParams() == null) { |
||||
return filter; |
||||
} |
||||
|
||||
Map parentParams = dto.getEventParams(); |
||||
Object billNumber = parentParams.get(PARAM_BILL_NUMBER); |
||||
if (billNumber != null && !billNumber.toString().isEmpty()) { |
||||
filter.add(new FilterItem(FIELD_NUMBER, "=", billNumber.toString())); |
||||
filter.add(new FilterItem("history", "=", "0")); |
||||
} |
||||
return filter; |
||||
} |
||||
} |
||||
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
import apelet.common.online.abstractplugin.ListPlugin; |
||||
import apelet.common.orm.impl.Filter; |
||||
import apelet.common.orm.impl.FilterItem; |
||||
import apelet.common.online.plugin.BeforeExecuteOperationArgs; |
||||
import apelet.common.online.plugin.OperationResult; |
||||
import apelet.common.online.plugin.OperationServicePlugIn; |
||||
|
||||
/** |
||||
* @ClassName: MembershipApplyListFilterPlugin |
||||
* @Author: huangdehua |
||||
* @Date: 2026/5/9 |
||||
* @Description: 入会申请列表过滤插件 |
||||
* 在列表加载前添加过滤条件,只显示最新单据(is_history=0) |
||||
*/ |
||||
public class MembershipApplyListFilterPlugin extends ListPlugin { |
||||
/** |
||||
* 是否历史字段 |
||||
*/ |
||||
private static final String FIELD_IS_HISTORY = "history"; |
||||
|
||||
/** |
||||
* 非历史记录 |
||||
*/ |
||||
private static final String IS_HISTORY_NO = "0"; |
||||
|
||||
@Override |
||||
protected Filter getFilter() { |
||||
Filter filter = new Filter(); |
||||
filter.add(new FilterItem(FIELD_IS_HISTORY, "!=", IS_HISTORY_NO)); |
||||
return filter; |
||||
} |
||||
} |
||||
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.ShowParameter; |
||||
import apelet.common.online.model.constant.ShowTypeEnum; |
||||
import apelet.common.online.model.constant.ViewStatus; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName: MembershipPayPopupPlugin |
||||
* @Author: huangdehua |
||||
* @Date: 2026/4/30 09:37 |
||||
* @Description: |
||||
*/ |
||||
public class MembershipPayPopupPlugin extends ExecutePluginParent { |
||||
|
||||
/** |
||||
* 目标表单ID - membershipFeePay 表单在平台中的表单ID |
||||
*/ |
||||
private static final Object FORM_ID = "2049040032123064320"; |
||||
|
||||
/** |
||||
* 触发按钮的标识 - 对应表单上按钮的 key/标识 |
||||
* 点击此按钮时触发弹窗 |
||||
*/ |
||||
private static final String BUTTON_KEY = "会费缴纳"; |
||||
|
||||
/** |
||||
* 按钮点击事件 |
||||
* 点击按钮时,以弹窗方式打开 membershipFeePay 表单 |
||||
* |
||||
* @param buttonKey 按钮标识 |
||||
* @param objectValue 当前表单数据对象 |
||||
*/ |
||||
@Override |
||||
public void buttonTriggered(String buttonKey, ObjectValue objectValue) { |
||||
// 仅响应指定按钮的点击事件
|
||||
if (!BUTTON_KEY.equals(buttonKey)) { |
||||
return; |
||||
} |
||||
|
||||
// 调用 showForm 打开 membershipFeePay 表单
|
||||
ShowParameter showParameter = new ShowParameter(); |
||||
showParameter.setFormId(FORM_ID.toString()); |
||||
showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); |
||||
showParameter.setStatus(ViewStatus.EDIT); |
||||
Map<String, Object> customParam = new HashMap<>(); |
||||
customParam.put("id"," "); |
||||
showParameter.setCustomParam(customParam); |
||||
super.showForm(showParameter); |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
|
||||
/** |
||||
* @ClassName: MembershipPayShowHidePlugin |
||||
* @Author: huangdehua |
||||
* @Date: 2026/5/7 15:00 |
||||
* @Description: 会费缴纳界面会员类别为非会员时显示银行收款凭证号字段,其他情况隐藏 |
||||
*/ |
||||
public class MembershipPayShowHidePlugin extends ExecutePluginParent { |
||||
@Override |
||||
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||
super.formCreated(widgetVariableName, objectValue); |
||||
String membershipType = objectValue.getString("membershipType"); |
||||
if (Objects.equals(membershipType, "E")){ |
||||
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, true); |
||||
}else { |
||||
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, false); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void change(String widgetVariableName, ObjectValue objectValue) { |
||||
super.change(widgetVariableName, objectValue); |
||||
String membershipType = objectValue.getString("membership_type"); |
||||
if (Objects.equals(widgetVariableName, "membershipType")){ |
||||
if (Objects.equals(membershipType, "E")){ |
||||
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, true); |
||||
}else { |
||||
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, false); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,466 @@
@@ -0,0 +1,466 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* @ClassName: UnitNameChangeFormInitPlugin |
||||
* @Author: huangdehua |
||||
* @Date: 2026/5/9 |
||||
* @Description: 入会申请与审核表单初始化插件(变更模式) |
||||
* 如果是从"变更"按钮弹出的表单,则设置其他字段为只读,只有单位名称可编辑 |
||||
*/ |
||||
public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
||||
|
||||
/** |
||||
* 来源参数key - 单据ID |
||||
*/ |
||||
private static final String PARAM_BILL_ID = "sourceBillId"; |
||||
private static final String PARAM_BILL_ID_ALT = "srcbillid"; |
||||
|
||||
/** |
||||
* 来源参数key - 单据编号 |
||||
*/ |
||||
private static final String PARAM_BILL_NUMBER = "sourceBillNumber"; |
||||
|
||||
private static final String CHILD_TABLE_NAME = "membership_apply_entry"; |
||||
|
||||
private static final String CHILD_PARENT_FIELD = "parent_id"; |
||||
|
||||
private static final String CHILD_WIDGET_KEY = "table1777360622546"; |
||||
|
||||
/** |
||||
* 需要设置为只读的字段列表(除单位名称外) |
||||
*/ |
||||
private static final String[] READONLY_FIELDS = { |
||||
"id", // 主键
|
||||
"number", // 单据编号
|
||||
"billstatus", // 单据状态
|
||||
"membershipMangerId",// 会员负责人
|
||||
"natureUnit", // 单位性质
|
||||
"menbershipAttributes",// 会员属性
|
||||
"scopeBusiness", // 业务经营范围
|
||||
"membershipType", // 会员类型
|
||||
"businessRegistNumber",// 工商注册号
|
||||
"registCapital", // 注册资金
|
||||
"registTime", // 注册时间
|
||||
"companyAddress", // 企业地址
|
||||
"history", // 是否历史
|
||||
"versionNumber", // 版本号
|
||||
"membership_apply_entry", |
||||
"table1777360622546" |
||||
}; |
||||
|
||||
/** |
||||
* 允许在变更模式下编辑的字段列表(单位名称相关) |
||||
*/ |
||||
private static final String[] EDITABLE_UNIT_NAME_FIELDS = { |
||||
"unitName", |
||||
"unitname" |
||||
}; |
||||
|
||||
private static final Map<String, String> FIELD_WIDGET_MAPPING = new HashMap<>(); |
||||
|
||||
static { |
||||
FIELD_WIDGET_MAPPING.put("create_user_id", "createUserId"); |
||||
FIELD_WIDGET_MAPPING.put("create_time", "createTime"); |
||||
FIELD_WIDGET_MAPPING.put("update_user_id", "updateUserId"); |
||||
FIELD_WIDGET_MAPPING.put("update_time", "updateTime"); |
||||
FIELD_WIDGET_MAPPING.put("deleted_flag", "deletedFlag"); |
||||
FIELD_WIDGET_MAPPING.put("is_history", "history"); |
||||
FIELD_WIDGET_MAPPING.put("nature_unit", "natureUnit"); |
||||
FIELD_WIDGET_MAPPING.put("unit_name", "unitName"); |
||||
FIELD_WIDGET_MAPPING.put("membership_manger_id", "membershipMangerId"); |
||||
FIELD_WIDGET_MAPPING.put("membership_type", "membershipType"); |
||||
FIELD_WIDGET_MAPPING.put("menbership_attributes", "menbershipAttributes"); |
||||
FIELD_WIDGET_MAPPING.put("scope_business", "scopeBusiness"); |
||||
FIELD_WIDGET_MAPPING.put("business_regist_number", "businessRegistNumber"); |
||||
FIELD_WIDGET_MAPPING.put("regist_capital", "registCapital"); |
||||
FIELD_WIDGET_MAPPING.put("regist_time", "registTime"); |
||||
FIELD_WIDGET_MAPPING.put("company_address", "companyAddress"); |
||||
FIELD_WIDGET_MAPPING.put("version_number", "versionNumber"); |
||||
FIELD_WIDGET_MAPPING.put(CHILD_TABLE_NAME, CHILD_WIDGET_KEY); |
||||
} |
||||
|
||||
@Override |
||||
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||
super.formCreated(widgetVariableName, objectValue); |
||||
|
||||
// 获取源单据ID
|
||||
String sourceBillId = getSourceBillId(objectValue); |
||||
String sourceBillNumber = getSourceBillNumber(objectValue); |
||||
|
||||
// 如果没有源单据ID,说明不是变更操作,正常返回
|
||||
if (sourceBillId == null || sourceBillId.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
// 这是从"变更"按钮弹出的表单
|
||||
// 1. 查询源单据数据并填充到当前表单
|
||||
fillSourceBillData(objectValue, sourceBillId, sourceBillNumber); |
||||
|
||||
// 2. 设置其他字段为只读,只有单位名称可编辑
|
||||
setFieldsReadonly(); |
||||
|
||||
//3.隐藏按钮
|
||||
this.setWidgetAttribute("submit", AttributeEnum.SHOW, false); |
||||
this.setWidgetAttribute("审核", AttributeEnum.SHOW, true); |
||||
this.setWidgetAttribute("table-btn primary", AttributeEnum.SHOW, false); |
||||
} |
||||
|
||||
@Override |
||||
public void buttonTriggered(String widgetVariableName, ObjectValue objectValue) { |
||||
super.buttonTriggered(widgetVariableName, objectValue); |
||||
if (!"保存".equals(widgetVariableName)) { |
||||
return; |
||||
} |
||||
|
||||
if (!isChangeBill(objectValue)) { |
||||
return; |
||||
} |
||||
|
||||
try { |
||||
saveChangeBillManually(objectValue); |
||||
this.cancelOperate(); |
||||
this.showMessage("保存成功"); |
||||
} catch (Exception e) { |
||||
this.cancelOperate(); |
||||
this.showErrorMessage("保存失败:" + e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
private boolean isChangeBill(ObjectValue objectValue) { |
||||
if (objectValue == null) { |
||||
return false; |
||||
} |
||||
|
||||
String sourceBillId = getSourceBillId(objectValue); |
||||
if (sourceBillId == null || sourceBillId.trim().isEmpty()) { |
||||
sourceBillId = objectValue.getString(PARAM_BILL_ID_ALT); |
||||
} |
||||
return sourceBillId != null && !sourceBillId.trim().isEmpty(); |
||||
} |
||||
|
||||
private void saveChangeBillManually(ObjectValue objectValue) throws Exception { |
||||
OrmGenDataSourceUtil ormUtil = (OrmGenDataSourceUtil) ormGenDataSourceUtil(); |
||||
if (ormUtil == null) { |
||||
throw new RuntimeException("获取数据库连接失败"); |
||||
} |
||||
|
||||
ObjectValue newBill = new ObjectValue("membership_apply"); |
||||
Map values = objectValue.getValues(); |
||||
for (Object item : values.entrySet()) { |
||||
Map.Entry entry = (Map.Entry) item; |
||||
String key = entry.getKey().toString(); |
||||
if (shouldSkipManualSaveField(key)) { |
||||
continue; |
||||
} |
||||
newBill.put(getDbFieldKey(key), entry.getValue()); |
||||
} |
||||
|
||||
ObjectCollection detailEntry = copyEntryForManualSave(objectValue.getObjectCollection(CHILD_WIDGET_KEY)); |
||||
if (detailEntry != null && !detailEntry.isEmpty()) { |
||||
newBill.put(CHILD_TABLE_NAME, detailEntry); |
||||
} |
||||
|
||||
ormUtil.addNew("membership_apply", newBill); |
||||
} |
||||
|
||||
private boolean shouldSkipManualSaveField(String key) { |
||||
return "id".equals(key) |
||||
|| "eventparams".equals(key) |
||||
|| PARAM_BILL_ID.equals(key) |
||||
|| PARAM_BILL_ID_ALT.equals(key) |
||||
|| PARAM_BILL_NUMBER.equals(key) |
||||
|| CHILD_TABLE_NAME.equals(key) |
||||
|| CHILD_WIDGET_KEY.equals(key); |
||||
} |
||||
|
||||
private String getDbFieldKey(String widgetKey) { |
||||
for (Map.Entry<String, String> entry : FIELD_WIDGET_MAPPING.entrySet()) { |
||||
if (entry.getValue().equals(widgetKey)) { |
||||
return entry.getKey(); |
||||
} |
||||
} |
||||
return widgetKey; |
||||
} |
||||
|
||||
private ObjectCollection copyEntryForManualSave(ObjectCollection sourceEntry) { |
||||
if (sourceEntry == null || sourceEntry.isEmpty()) { |
||||
return null; |
||||
} |
||||
|
||||
ObjectCollection targetEntry = new ObjectCollection(); |
||||
for (int i = 0; i < sourceEntry.size(); i++) { |
||||
ObjectValue sourceRow = sourceEntry.getObject(i); |
||||
if (sourceRow == null) { |
||||
continue; |
||||
} |
||||
|
||||
ObjectValue targetRow = new ObjectValue(CHILD_TABLE_NAME); |
||||
Map rowValues = sourceRow.getValues(); |
||||
for (Object item : rowValues.entrySet()) { |
||||
Map.Entry entry = (Map.Entry) item; |
||||
String key = entry.getKey().toString(); |
||||
if ("id".equals(key) || CHILD_PARENT_FIELD.equals(key)) { |
||||
continue; |
||||
} |
||||
targetRow.put(key, entry.getValue()); |
||||
} |
||||
targetEntry.addObject(targetRow); |
||||
} |
||||
return targetEntry; |
||||
} |
||||
|
||||
/** |
||||
* 从ObjectValue中获取源单据ID |
||||
* 从 eventparams 中获取 |
||||
*/ |
||||
private String getSourceBillId(ObjectValue objectValue) { |
||||
Object eventparams = objectValue.get("eventparams"); |
||||
if (eventparams instanceof JSONObject){ |
||||
JSONObject params = (JSONObject) eventparams; |
||||
String sourceBillId = params.getString(PARAM_BILL_ID); |
||||
if (sourceBillId == null || sourceBillId.isEmpty()) { |
||||
sourceBillId = params.getString(PARAM_BILL_ID_ALT); |
||||
} |
||||
return sourceBillId; |
||||
} |
||||
if (eventparams instanceof Map) { |
||||
Map params = (Map) eventparams; |
||||
Object sourceBillId = params.get(PARAM_BILL_ID); |
||||
if (sourceBillId == null || sourceBillId.toString().isEmpty()) { |
||||
sourceBillId = params.get(PARAM_BILL_ID_ALT); |
||||
} |
||||
return sourceBillId == null ? null : sourceBillId.toString(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 从ObjectValue中获取源单据编号 |
||||
* 从 eventparams 中获取 |
||||
*/ |
||||
private String getSourceBillNumber(ObjectValue objectValue) { |
||||
Object eventparams = objectValue.get("eventparams"); |
||||
if (eventparams instanceof JSONObject){ |
||||
return ((JSONObject) eventparams).getString(PARAM_BILL_NUMBER); |
||||
} |
||||
if (eventparams instanceof Map) { |
||||
Object sourceBillNumber = ((Map) eventparams).get(PARAM_BILL_NUMBER); |
||||
return sourceBillNumber == null ? null : sourceBillNumber.toString(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 设置字段为只读 |
||||
* 只有单位名称字段可编辑,其他字段全部只读 |
||||
*/ |
||||
private void setFieldsReadonly() { |
||||
// 设置所有需要只读的字段为禁用(不可编辑)
|
||||
for (String field : READONLY_FIELDS) { |
||||
try { |
||||
this.setWidgetAttribute(field, AttributeEnum.DISABLED, true); |
||||
} catch (Exception e) { |
||||
// 字段可能不存在,忽略异常
|
||||
} |
||||
} |
||||
|
||||
// 确保单位名称字段可编辑
|
||||
for (String field : EDITABLE_UNIT_NAME_FIELDS) { |
||||
try { |
||||
this.setWidgetAttribute(field, AttributeEnum.DISABLED, false); |
||||
this.setWidgetAttribute(field, AttributeEnum.SHOW, true); |
||||
} catch (Exception e) { |
||||
// 字段可能不存在,忽略异常
|
||||
} |
||||
} |
||||
|
||||
// 禁用子表
|
||||
try { |
||||
this.setWidgetAttribute("membership_apply_entry", AttributeEnum.DISABLED, true); |
||||
this.setWidgetAttribute("membershipApplyEntry", AttributeEnum.DISABLED, true); |
||||
this.setWidgetAttribute("table1777360622546", AttributeEnum.DISABLED, true); |
||||
} catch (Exception e) { |
||||
// 子表可能不存在,忽略异常
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取源单据数据并填充到当前表单 |
||||
* |
||||
* @param objectValue 当前表单数据对象 |
||||
* @param sourceBillId 源单据ID |
||||
* @param sourceBillNumber 源单据编号 |
||||
*/ |
||||
private void fillSourceBillData(ObjectValue objectValue, String sourceBillId, String sourceBillNumber) { |
||||
try { |
||||
// 从数据库查询源单据数据
|
||||
apelet.common.generator.utils.OrmGenDataSourceUtil ormUtil = (OrmGenDataSourceUtil) ormGenDataSourceUtil(); |
||||
if (ormUtil == null) { |
||||
return; |
||||
} |
||||
|
||||
// 构建查询条件
|
||||
apelet.common.orm.impl.Filter filter = new apelet.common.orm.impl.Filter(); |
||||
if (sourceBillId != null && !sourceBillId.isEmpty()) { |
||||
filter.add(new apelet.common.orm.impl.FilterItem("id", "=", sourceBillId)); |
||||
} else if (sourceBillNumber != null && !sourceBillNumber.isEmpty()) { |
||||
filter.add(new apelet.common.orm.impl.FilterItem("number", "=", sourceBillNumber)); |
||||
} else { |
||||
return; |
||||
} |
||||
|
||||
ObjectCollection sourceCollection = ormUtil.query("membership_apply", filter, null); |
||||
if (sourceCollection == null || sourceCollection.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
ObjectValue sourceBill = sourceCollection.getObject(0); |
||||
if (sourceBill == null) { |
||||
return; |
||||
} |
||||
|
||||
// 将源单据的数据填充到当前表单(除了ID和状态字段)
|
||||
Map<String, Object> values = sourceBill.getValues(); |
||||
for (Map.Entry<String, Object> entry : values.entrySet()) { |
||||
String key = entry.getKey(); |
||||
Object value = entry.getValue(); |
||||
|
||||
// 跳过ID和状态字段,这些字段由系统处理
|
||||
if ("id".equals(key) || "billstatus".equals(key) || |
||||
"is_history".equals(key) || "version_number".equals(key) || |
||||
"isHistory".equals(key) || "versionNumber".equals(key)) { |
||||
continue; |
||||
} |
||||
|
||||
// 设置字段值到ObjectValue
|
||||
String widgetKey = getWidgetKey(key); |
||||
objectValue.put(widgetKey, value); |
||||
|
||||
// 设置字段值到表单控件
|
||||
try { |
||||
this.setWidgetAttribute("id",AttributeEnum.VALUE_CHANGE,null); |
||||
this.setWidgetAttribute(widgetKey, AttributeEnum.VALUE_CHANGE, value); |
||||
} catch (Exception e) { |
||||
// 字段可能不存在,忽略异常
|
||||
} |
||||
} |
||||
|
||||
syncHistoryAndVersionForChangeBill(objectValue, ormUtil, sourceBill); |
||||
|
||||
// 保存源单据ID作为标识(用于后续业务逻辑)
|
||||
fillSourceBillEntryData(objectValue, ormUtil, sourceBillId); |
||||
objectValue.put(PARAM_BILL_ID, sourceBillId); |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private String getWidgetKey(String fieldKey) { |
||||
String widgetKey = FIELD_WIDGET_MAPPING.get(fieldKey); |
||||
return widgetKey == null ? fieldKey : widgetKey; |
||||
} |
||||
|
||||
private void syncHistoryAndVersionForChangeBill(ObjectValue objectValue, |
||||
OrmGenDataSourceUtil ormUtil, |
||||
ObjectValue sourceBill) throws Exception { |
||||
if (sourceBill == null) { |
||||
return; |
||||
} |
||||
|
||||
String number = sourceBill.getString("number"); |
||||
if (number == null || number.trim().isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
apelet.common.orm.impl.Filter sameNumberFilter = new apelet.common.orm.impl.Filter(); |
||||
sameNumberFilter.add(new apelet.common.orm.impl.FilterItem("number", "=", number)); |
||||
ObjectCollection sameBills = ormUtil.query("membership_apply", sameNumberFilter, null); |
||||
|
||||
int version = 1; |
||||
if (sameBills != null && !sameBills.isEmpty()) { |
||||
List<ObjectValue> bills = new java.util.ArrayList<>(); |
||||
for (int i = 0; i < sameBills.size(); i++) { |
||||
ObjectValue bill = sameBills.getObject(i); |
||||
if (bill != null) { |
||||
bills.add(bill); |
||||
} |
||||
} |
||||
|
||||
bills.sort(java.util.Comparator.comparingInt(this::getVersionNumberSafe)); |
||||
for (ObjectValue bill : bills) { |
||||
bill.put("is_history", 1); |
||||
bill.put("version_number", version); |
||||
ormUtil.update("membership_apply", bill, null); |
||||
version++; |
||||
} |
||||
} |
||||
|
||||
objectValue.put("is_history", 0); |
||||
objectValue.put("history", 0); |
||||
objectValue.put("version_number", version); |
||||
objectValue.put("versionNumber", version); |
||||
|
||||
try { |
||||
this.setWidgetAttribute("history", AttributeEnum.VALUE_CHANGE, "0"); |
||||
this.setWidgetAttribute("versionNumber", AttributeEnum.VALUE_CHANGE, version); |
||||
} catch (Exception e) { |
||||
// 字段可能不存在,忽略异常
|
||||
} |
||||
} |
||||
|
||||
private int getVersionNumberSafe(ObjectValue bill) { |
||||
if (bill == null) { |
||||
return 0; |
||||
} |
||||
Object value = bill.getValues().get("version_number"); |
||||
if (value == null) { |
||||
value = bill.getValues().get("versionNumber"); |
||||
} |
||||
if (value == null) { |
||||
return 0; |
||||
} |
||||
try { |
||||
return Integer.parseInt(value.toString()); |
||||
} catch (Exception e) { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
private void fillSourceBillEntryData(ObjectValue objectValue, OrmGenDataSourceUtil ormUtil, String sourceBillId) throws Exception { |
||||
if (sourceBillId == null || sourceBillId.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
apelet.common.orm.impl.Filter entryFilter = new apelet.common.orm.impl.Filter(); |
||||
entryFilter.add(new apelet.common.orm.impl.FilterItem(CHILD_PARENT_FIELD, "=", sourceBillId)); |
||||
ObjectCollection entryCollection = ormUtil.query(CHILD_TABLE_NAME, entryFilter, null); |
||||
if (entryCollection == null) { |
||||
return; |
||||
} |
||||
ObjectCollection detailEntry = objectValue.getObjectCollection(CHILD_WIDGET_KEY); |
||||
if (detailEntry == null) { |
||||
detailEntry = new ObjectCollection(); |
||||
} |
||||
detailEntry.addObjectCollection(entryCollection); |
||||
|
||||
objectValue.put(CHILD_WIDGET_KEY, detailEntry); |
||||
try { |
||||
this.setWidgetAttribute(CHILD_WIDGET_KEY, AttributeEnum.VALUE_CHANGE, detailEntry); |
||||
} catch (Exception e) { |
||||
// 字段可能不存在,忽略异常
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
|
||||
/** |
||||
* @ClassName: UnitNameChangeFormPlugin |
||||
* @Author: huangdehua |
||||
* @Date: 2026/4/30 10:40 |
||||
* @Description: 入会申请与审核界面初始化 |
||||
*/ |
||||
public class UnitNameChangeFormPlugin extends ExecutePluginParent { |
||||
|
||||
/** |
||||
* 界面初始化事件 |
||||
* 将单据状态 billStatus 赋值为 "A" |
||||
*/ |
||||
@Override |
||||
public void formCreated(String str, ObjectValue objectValue) { |
||||
super.formCreated(str, objectValue); |
||||
//objectValue.setString("billStatus", "A");
|
||||
//this.setWidgetAttribute("billstatus", AttributeEnum.VALUE_CHANGE, "A");
|
||||
} |
||||
} |
||||
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.ShowParameter; |
||||
import apelet.common.online.model.constant.ShowTypeEnum; |
||||
import apelet.common.online.model.constant.ViewStatus; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName: UnitNameChangePopupPlugin |
||||
* @Author: huangdehua |
||||
* @Date: 2026/5/9 |
||||
* @Description: 入会申请与审核 - 变更单位名称弹窗插件 |
||||
* 点击"变更"按钮时,弹出入会申请表单,并将列表中选中行数据带入弹窗中 |
||||
*/ |
||||
public class UnitNameChangePopupPlugin extends ExecutePluginParent { |
||||
|
||||
/** |
||||
* 目标表单ID - membership_apply 表单在平台中的表单ID |
||||
*/ |
||||
private static final String TARGET_FORM_ID = "2048951917157027840"; |
||||
|
||||
/** |
||||
* 触发按钮的标识 - 对应表单上按钮的 key/标识 |
||||
*/ |
||||
private static final String BUTTON_KEY = "变更"; |
||||
|
||||
/** |
||||
* 列表页面中表格控件的变量名/key |
||||
*/ |
||||
private static final String TABLE_WIDGET_KEY = "table1777354992881"; |
||||
|
||||
/** |
||||
* 传递到弹窗的参数key - 单据ID |
||||
*/ |
||||
private static final String PARAM_BILL_ID = "sourceBillId"; |
||||
|
||||
/** |
||||
* 传递到弹窗的参数key - 单据编号 |
||||
*/ |
||||
private static final String PARAM_BILL_NUMBER = "sourceBillNumber"; |
||||
|
||||
/** |
||||
* 按钮点击事件(列表按钮) |
||||
* 点击"变更"按钮时,通过 getSelectData 获取列表中选中行的单据数据, |
||||
* 以弹窗方式打开入会申请表单,并将选中行数据带入 |
||||
* |
||||
* @param buttonKey 按钮标识 |
||||
* @param objectValue 列表按钮事件数据对象(非表单数据) |
||||
*/ |
||||
@Override |
||||
public void buttonTriggered(String buttonKey, ObjectValue objectValue) { |
||||
// 仅响应"变更"按钮的点击事件
|
||||
if (!BUTTON_KEY.equals(buttonKey)) { |
||||
return; |
||||
} |
||||
|
||||
// 【列表场景】通过框架提供的 getSelectData 方法获取选中/点击行的数据
|
||||
// objectValue 中的 rowdata 包含列表所有行,getSelectData 会找到
|
||||
// 标记了 isClick=true(点击行)或 isSelect=true(勾选行)的那一行
|
||||
Map<String, Object> selectedRow = getSelectData(objectValue, TABLE_WIDGET_KEY); |
||||
|
||||
if (selectedRow == null) { |
||||
showWarningMessage("请先在列表中选中一条单据"); |
||||
return; |
||||
} |
||||
|
||||
// 从选中行中获取单据ID和编号
|
||||
String billId = selectedRow.get("id") != null ? selectedRow.get("id").toString() : ""; |
||||
String billNumber = selectedRow.get("number") != null ? selectedRow.get("number").toString() : ""; |
||||
|
||||
if (billId.isEmpty()) { |
||||
showWarningMessage("选中的单据缺少ID信息,请重新选择"); |
||||
return; |
||||
} |
||||
|
||||
// 调用 showForm 打开入会申请表单(新建空表单,不加载任何已有记录)
|
||||
ShowParameter showParameter = new ShowParameter(); |
||||
showParameter.setFormId(TARGET_FORM_ID); |
||||
showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); |
||||
showParameter.setStatus(ViewStatus.EDIT); |
||||
showParameter.setPkId(null); // 明确指定为空,表示新建表单而非打开已有单据
|
||||
|
||||
// 设置自定义参数,用于在目标表单中获取源单据数据
|
||||
Map<String, Object> customParam = new HashMap<>(); |
||||
customParam.put(PARAM_BILL_ID, billId); |
||||
customParam.put(PARAM_BILL_NUMBER, billNumber); |
||||
showParameter.setCustomParam(customParam); |
||||
|
||||
super.showForm(showParameter); |
||||
} |
||||
} |
||||
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
package apelet.association.plugin.member; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
import apelet.common.online.dto.OnlineEventPluginExecuteDto; |
||||
import apelet.common.orm.impl.Filter; |
||||
import apelet.common.orm.impl.FilterItem; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.ShowParameter; |
||||
import apelet.common.online.model.constant.ShowTypeEnum; |
||||
import apelet.common.online.model.constant.ViewStatus; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName: ViewHistoryBillOperationPlugin |
||||
* @Author: huangdehua |
||||
* @Date: 2026/5/9 |
||||
* @Description: 查看历史单据操作插件 |
||||
* 点击"查看历史"按钮时,弹出一个显示当前选中单据所有历史变更记录的列表 |
||||
*/ |
||||
public class ViewHistoryBillOperationPlugin extends ExecutePluginParent { |
||||
|
||||
/** |
||||
* 触发按钮的标识 - 对应表单上按钮的 key/标识 |
||||
*/ |
||||
private static final String BUTTON_KEY = "查看历史"; |
||||
|
||||
|
||||
/** |
||||
* 历史单据列表表单ID |
||||
* 需要在平台配置中创建历史单据列表表单并配置此ID |
||||
*/ |
||||
private static final String HISTORY_LIST_FORM_ID = "2071862530363363328"; |
||||
|
||||
/** |
||||
* 传递到历史列表的参数key - 单据编号 |
||||
*/ |
||||
private static final String PARAM_BILL_NUMBER = "billNumber"; |
||||
|
||||
/** |
||||
* 主表名 |
||||
*/ |
||||
private static final String TABLE_NAME = "membership_apply"; |
||||
|
||||
/** |
||||
* 字段:单据编号 |
||||
*/ |
||||
private static final String FIELD_NUMBER = "number"; |
||||
|
||||
|
||||
/** |
||||
* 按钮点击事件(列表按钮) |
||||
* 点击"查看历史"按钮时,通过 getSelectData 获取列表中选中行的单据编号, |
||||
* 查询该编号的所有历史记录并打开历史单据列表 |
||||
* |
||||
* @param buttonKey 按钮标识 |
||||
* @param objectValue 列表按钮事件数据对象 |
||||
*/ |
||||
@Override |
||||
public void buttonTriggered(String buttonKey, ObjectValue objectValue) { |
||||
// 仅响应"查看历史"按钮的点击事件
|
||||
if (!BUTTON_KEY.equals(buttonKey)) { |
||||
return; |
||||
} |
||||
|
||||
|
||||
OnlineEventPluginExecuteDto dto = getDto(); |
||||
List<Map> rowDatas = dto.getModel().getRowDatas(); |
||||
if (rowDatas == null || rowDatas.size() != 1) { |
||||
showWarningMessage("请先在列表中选中一条单据"); |
||||
this.cancelOperate(); |
||||
return; |
||||
} |
||||
Map data = rowDatas.get(0); |
||||
|
||||
// 从选中行中获取单据编号
|
||||
Object numberObj = data.get(FIELD_NUMBER); |
||||
String billNumber = (numberObj != null) ? numberObj.toString() : ""; |
||||
if (billNumber.isEmpty()) { |
||||
showWarningMessage("选中的单据缺少编号信息,请重新选择"); |
||||
return; |
||||
} |
||||
|
||||
// 查询该单据的所有历史记录
|
||||
ObjectCollection historyList = queryHistoryBills(billNumber); |
||||
if (historyList == null || historyList.size() <= 1) { |
||||
showWarningMessage("该单据暂无历史变更记录"); |
||||
return; |
||||
} |
||||
|
||||
// 打开历史单据列表弹窗
|
||||
openHistoryListPopup(billNumber); |
||||
} |
||||
|
||||
/** |
||||
* 查询单据的历史记录 |
||||
* |
||||
* @param billNumber 单据编号 |
||||
* @return 历史单据集合 |
||||
*/ |
||||
private ObjectCollection queryHistoryBills(String billNumber) { |
||||
try { |
||||
OrmGenDataSourceUtil ormUtil = (OrmGenDataSourceUtil) ormGenDataSourceUtil(); |
||||
if (ormUtil == null) { |
||||
return null; |
||||
} |
||||
|
||||
// 查询条件:相同单据编号的所有记录(按版本号降序)
|
||||
Filter filter = new Filter(); |
||||
filter.add(new FilterItem(FIELD_NUMBER, "=", billNumber)); |
||||
|
||||
|
||||
ObjectCollection result = ormUtil.query(TABLE_NAME, filter, null); |
||||
return result; |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 打开历史单据列表弹窗 |
||||
* |
||||
* @param billNumber 单据编号 |
||||
*/ |
||||
private void openHistoryListPopup(String billNumber) { |
||||
ShowParameter showParameter = new ShowParameter(); |
||||
showParameter.setFormId(HISTORY_LIST_FORM_ID); |
||||
showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); |
||||
showParameter.setStatus(ViewStatus.VIEW); |
||||
|
||||
// 设置自定义参数
|
||||
Map<String, Object> customParam = new HashMap<>(); |
||||
customParam.put(PARAM_BILL_NUMBER, billNumber); |
||||
showParameter.setCustomParam(customParam); |
||||
|
||||
super.showForm(showParameter); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
package apelet.association.utils; |
||||
|
||||
import java.time.LocalDate; |
||||
import java.time.format.DateTimeFormatter; |
||||
|
||||
public class CreatNumberUtils { |
||||
public String creatNumber() { |
||||
return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue