提交人:陈绍鑫

日期:2025/6/6 12:30
内容:按钮冷却10秒
This commit is contained in:
陈绍鑫 2025-06-11 17:48:21 +08:00
parent 437010f5f6
commit 69a40551c8
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,62 @@
package shkd.sys.sys.plugin.list;
import kd.bos.form.IPageCache;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.list.IListView;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import org.apache.commons.lang3.StringUtils;
import shkd.sys.sys.plugin.list.domain.OverTimeVarietyEnum;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.EventObject;
import java.util.List;
import java.util.Map;
public class ElectronicPayDealListPlugin extends AbstractListPlugin {
private static final Log logger = LogFactory.getLog(ElectronicPayDealListPlugin.class);
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
}
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
super.beforeItemClick(evt);
String itemKey = evt.getItemKey();
String billFormId = ((IListView) this.getView()).getBillFormId();
Map<String, List<String>> qtqyrz = OverTimeVarietyEnum.qtqyrz;
List<String> list = qtqyrz.get(billFormId);
if (list!=null&&list.contains(itemKey)){
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
IPageCache iPageCache =this.getPageCache();
String LastTime = iPageCache.get("LastTime");
if(!StringUtils.isEmpty(LastTime)){
// 获取当前时间
LocalDateTime currentTime = LocalDateTime.now();
LocalDateTime localDateTime = LocalDateTime.parse(LastTime, formatter);
// 计算当前时间与另一个时间的时间差
Duration duration = Duration.between(localDateTime, currentTime);
// 判断时间差是否超过 10
if (duration.getSeconds() <= 10) {
this.getView().showTipNotification("该按钮点击间隔需要超过十秒");
evt.setCancel(true);
}else {
iPageCache.put("LastTime",currentTime.format(formatter));
}
}else {
iPageCache.put("LastTime",LocalDateTime.now().format(formatter));
}
}
}
}

View File

@ -0,0 +1,10 @@
package shkd.sys.sys.plugin.list.domain;
import java.util.*;
public class OverTimeVarietyEnum {
public static final Map<String, List<String>> qtqyrz = new HashMap() {{
put("cdm_electronic_pay_deal", new ArrayList<>(Arrays.asList("querynotepayable")));
put("银行借款合同", new ArrayList<>(Arrays.asList("其他权益融资")));
}};
}