共享任务中心,联查凭证预览凭证

This commit is contained in:
zhangzhiguo 2025-08-25 11:09:13 +08:00
parent 07f9df507b
commit d439ec2aa2
1 changed files with 77 additions and 0 deletions

View File

@ -1,13 +1,18 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.OperationStatus;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.cache.AppCache;
import kd.bos.entity.cache.IAppCache;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.operate.result.IOperateInfo;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.form.FormShowParameter;
import kd.bos.form.IFormView;
import kd.bos.form.ShowType;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.BillList;
@ -22,6 +27,8 @@ import kd.ssc.task.formplugin.util.VoucherUtil;
import java.util.*;
import static kd.bamp.mbis.webapi.constant.apiconstant.CardActionApiConstant.billid;
/**
* 共享任务中心-我的任务-批量生成凭证插件
*/
@ -38,6 +45,55 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
handleBuildVoucher();
} else if ("zcgj_deletevoucher".equals(itemKey)) {
handleDeleteVoucher();
} else if("zcgj_tracevoucher".equals(itemKey)){ //联查凭证
BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
if(selectedRows!=null){
if(selectedRows.size()==1){
DynamicObject task = BusinessDataServiceHelper.loadSingle((Long) selectedRows.get(0).getPrimaryKeyValue(), "task_task");
String billId = task.getString("billid");
VoucherUtil.viewVoucher(billId, this.getView(), true);
}else{
this.getView().showTipNotification("请选择一条数据进行查看凭证。");
return;
}
}else{
this.getView().showTipNotification("请选择一条数据进行查看凭证。");
return;
}
}else if("zcgj_previewvoucher".equals(itemKey)){ //凭证预览
Map<String, Object> voucherOperate = null;
OperateOption option = OperateOption.create();
IFormView view = this.getView();
OperationResult operationResult = null;
try {
BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
if(selectedRows.size()==1){
DynamicObject task = BusinessDataServiceHelper.loadSingle((Long) selectedRows.get(0).getPrimaryKeyValue(), "task_task");
String entityName = task.getDynamicObject("billtype").getDynamicObject("bindbill").getString("number");
String billId = task.getString("billid");
String billnumber = task.getString("billnumber");
voucherOperate = EntityMetadataCache.getDataEntityOperate(entityName, "previewvoucher");
option.setVariableValue("previewpageid", view.getPageId());
operationResult = OperationServiceHelper.executeOperate((String)voucherOperate.get("key"), entityName, new Object[]{billId}, option);
if (operationResult.isSuccess()) {
this.showPreVoucher(view);
} else {
List<IOperateInfo> allErrorInfo = operationResult.getAllErrorOrValidateInfo();
StringBuilder sb = new StringBuilder();
allErrorInfo.forEach((error) -> sb.append(error.getMessage()));
view.showTipNotification(sb.toString());
log.info("预览凭证失败单据id" + billId + ",失败原因:" + sb);
}
}else{
this.getView().showTipNotification("请选择一条数据进行预览凭证。");
return;
}
} catch (Exception e1) {
view.showErrorNotification(String.format(ResManager.loadKDString("预览凭证失败: %s", "TaskVoucherApproveFormPlugin_0", "ssc-task-formplugin", new Object[0]), e1.getMessage()));
}
}
}
@ -167,7 +223,28 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
this.getView().invokeOperation("refresh");
}
private void showPreVoucher(IFormView view) {
IAppCache cache = AppCache.get("gl");
String string = (String)cache.get("accSys_" + view.getPageId() + "_perviewvoucher", String.class);
String entityName = (String)cache.get("accSys_" + view.getPageId() + "_entityname", String.class);
String billId = (String)cache.get("accSys_" + view.getPageId() + "_billid", String.class);
String isevent = (String)cache.get("accSys_" + view.getPageId() + "_isevent", String.class);
if (kd.bos.dataentity.utils.StringUtils.isNotBlank(string)) {
String tempId = (String)cache.get("accSys_" + view.getPageId() + "_vchtemplateid", String.class);
FormShowParameter form = new FormShowParameter();
form.setFormId("ai_previewvoucher");
form.setCustomParam("voucher", string);
form.setCustomParam("entityname", entityName);
form.setCustomParam("isevent", isevent);
form.setCustomParam("billId", billId);
form.setCustomParam("tempId", tempId);
form.getOpenStyle().setShowType(ShowType.MainNewTabPage);
form.setStatus(OperationStatus.VIEW);
view.showForm(form);
}
cache.remove("accSys_" + view.getPageId() + "_perviewvoucher");
}
}