146 lines
6.2 KiB
Java
146 lines
6.2 KiB
Java
package tqq9.lc123.cloud.app.plugin.form.sys;
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
|
import kd.bos.form.CloseCallBack;
|
|
import kd.bos.form.FormShowParameter;
|
|
import kd.bos.form.ShowType;
|
|
import kd.bos.form.control.events.BeforeItemClickEvent;
|
|
import kd.bos.form.control.events.ItemClickEvent;
|
|
import kd.bos.form.events.ClosedCallBackEvent;
|
|
import kd.bos.form.events.HyperLinkClickArgs;
|
|
import kd.bos.list.BillList;
|
|
import kd.bos.list.IListView;
|
|
import kd.bos.list.plugin.AbstractListPlugin;
|
|
import kd.bos.logging.Log;
|
|
import kd.bos.logging.LogFactory;
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
import kd.sdk.plugin.Plugin;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.EventObject;
|
|
import java.util.HashMap;
|
|
|
|
/**
|
|
* 商品批次注册证管理界面插件
|
|
*/
|
|
public class GoodlotManageBillPlugin extends AbstractListPlugin implements Plugin {
|
|
private final static Log logger = LogFactory.getLog(GoodlotManageBillPlugin.class);
|
|
|
|
/**
|
|
* 控件监听
|
|
*/
|
|
@Override
|
|
public void registerListener(EventObject e) {
|
|
super.registerListener(e);
|
|
this.addItemClickListeners("tbmain");
|
|
this.addClickListeners("tqq9_lotcheck", "tqq9_customcheck");
|
|
|
|
}
|
|
|
|
/**
|
|
* 点击前事件,校验是否选择单行数据
|
|
*/
|
|
@Override
|
|
public void beforeItemClick(BeforeItemClickEvent evt) {
|
|
super.beforeItemClick(evt);
|
|
String itemKey = evt.getItemKey();
|
|
|
|
if (StringUtils.equals(itemKey, "tqq9_lotchecktb") || StringUtils.equals(itemKey, "tqq9_customchecktb")) {
|
|
BillList billList = (BillList) this.getControl("billlistap");
|
|
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
|
|
if (selectedRows.size() > 1) {
|
|
evt.setCancel(true);
|
|
this.getView().showMessage("请选择单行信息");
|
|
} else if (selectedRows.size() == 0) {
|
|
evt.setCancel(true);
|
|
this.getView().showMessage("请选择要执的单行信息");
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 点击跳转附件上传页面
|
|
*/
|
|
@Override
|
|
public void itemClick(ItemClickEvent evt) {
|
|
super.itemClick(evt);
|
|
String itemKey = evt.getItemKey();
|
|
if (StringUtils.equals(itemKey, "tqq9_lotchecktb") || StringUtils.equals(itemKey, "tqq9_customchecktb")) {
|
|
BillList billList = (BillList) this.getControl("billlistap");
|
|
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
|
|
Object[] ids = selectedRows.getPrimaryKeyValues();
|
|
Object id = ids[0];
|
|
FormShowParameter param = new FormShowParameter();
|
|
param.setFormId("tqq9_upload");
|
|
param.setCloseCallBack(new CloseCallBack(this, "tqq9_upload"));
|
|
param.getOpenStyle().setShowType(ShowType.Modal);
|
|
param.setCustomParam("buttontype", itemKey);
|
|
param.setCustomParam("id", id);
|
|
this.getView().showForm(param);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 附件上传页面回传附件信息
|
|
*/
|
|
@Override
|
|
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
|
super.closedCallBack(closedCallBackEvent);
|
|
String actionId = closedCallBackEvent.getActionId();
|
|
Object returnData = closedCallBackEvent.getReturnData();
|
|
if (returnData != null) {
|
|
if (StringUtils.equals("tqq9_upload", actionId)) {
|
|
ArrayList attachmentData = (ArrayList) ((HashMap) returnData).get("attachmentData");
|
|
HashMap<String, Object> map = (HashMap) attachmentData.get(0);
|
|
String url = map.get("url").toString();
|
|
HashMap creator = (HashMap) map.get("creator");
|
|
String name = creator.get("zh_CN").toString();
|
|
DynamicObject user = BusinessDataServiceHelper.loadSingle("bos_user", new QFilter[]{new QFilter("name", QCP.equals, name)});
|
|
Long uploadTime = (Long) map.get("uploadTime");
|
|
Date date = new Date(uploadTime);
|
|
String buttontype = ((HashMap) returnData).get("buttontype").toString();
|
|
Object id = ((HashMap) returnData).get("id");
|
|
DynamicObject tqq9_goodlotmanage = BusinessDataServiceHelper.loadSingle(id, "tqq9_goodlotmanage");
|
|
if (StringUtils.equals("tqq9_lotchecktb", buttontype)) {
|
|
tqq9_goodlotmanage.set("tqq9_lotcheck", url);//中台批次检测文件
|
|
tqq9_goodlotmanage.set("tqq9_lotcheckdate", date);//批次检测报告操作时间
|
|
tqq9_goodlotmanage.set("tqq9_lotcheckperson", user);//批次检测报表操作人
|
|
SaveServiceHelper.save(new DynamicObject[]{tqq9_goodlotmanage});
|
|
} else if (StringUtils.equals("tqq9_customchecktb", buttontype)) {
|
|
tqq9_goodlotmanage.set("tqq9_customcheck", url);//中台报关单文件
|
|
tqq9_goodlotmanage.set("tqq9_customcheckdate", date);//报关单操作时间
|
|
tqq9_goodlotmanage.set("tqq9_customcheckperson", user);//报关单操作人
|
|
SaveServiceHelper.save(new DynamicObject[]{tqq9_goodlotmanage});
|
|
}
|
|
getView().updateView();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 点击链接下载
|
|
*/
|
|
@Override
|
|
public void billListHyperLinkClick(HyperLinkClickArgs args) {
|
|
super.billListHyperLinkClick(args);
|
|
String fieldName = args.getFieldName();
|
|
args.setCancel(true);
|
|
if (StringUtils.equals("tqq9_lotcheck", fieldName) || StringUtils.equals("tqq9_customcheck", fieldName)) {
|
|
ListSelectedRowCollection selectedRows = ((IListView) this.getView()).getSelectedRows();
|
|
Object id = selectedRows.getPrimaryKeyValues()[0];
|
|
DynamicObject tqq9_goodlotmanage = BusinessDataServiceHelper.loadSingle(id, "tqq9_goodlotmanage");
|
|
String url = tqq9_goodlotmanage.getString(fieldName);
|
|
if (url != null) {
|
|
this.getView().download(url);
|
|
}
|
|
}
|
|
}
|
|
|
|
} |